Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool: reintroduce set file comment code for AmigaOS #9258

Closed
wants to merge 2 commits into from

Conversation

Futaura
Copy link
Contributor

@Futaura Futaura commented Aug 6, 2022

Amiga specific code which put the URL in the file comment was perhaps
accidentally removed in b889408 having
originally been added in 5c215bd.
Reworked to fit the code changes and added it back in.

Reported-by: Michael Trebilcock
Originally-added-by: Chris Young

Amiga specific code which put the URL in the file comment was perhaps
accidentally removed in b889408 having
originally been added in 5c215bd.
Reworked to fit the code changes and added it back in.

Reported-by: Michael Trebilcock
Originally-added-by: Chris Young
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making it an Amiga specific function that uses a blank macro for non-Amiga? In an attempt to maybe reduce the ifdefs within that already very complicated function. Maybe like this:

diff --git a/src/tool_operate.c b/src/tool_operate.c
index 839efb1a1..853e2fbb2 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -325,10 +325,25 @@ static CURLcode pre_transfer(struct GlobalConfig *global,
     per->input.fd = per->infd;
   }
   return result;
 }
 
+#ifdef __AMIGA__
+static void AmigaSetComment(CURLcode result,
+                            struct OutStruct *outs)
+{
+  if(!result && outs->s_isreg && outs->filename) {
+    /* Set the url (up to 80 chars) as comment for the file */
+    if(strlen(per->this_url) > 78)
+      per->this_url[79] = '\0';
+    SetComment(outs->filename, per->this_url);
+  }
+}
+#else
+#define AmigaSetComment(x,y)
+#endif
+
 /*
  * Call this after a transfer has completed.
  */
 static CURLcode post_per_transfer(struct GlobalConfig *global,
                                   struct per_transfer *per,
@@ -601,10 +616,12 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
       notef(global, "Removing output file: %s\n", outs->filename);
       unlink(outs->filename);
     }
   }
 
+  AmigaSetComment(result, outs);
+
   /* File time can only be set _after_ the file has been closed */
   if(!result && config->remote_time && outs->s_isreg && outs->filename) {
     /* Ask libcurl if we got a remote file time */
     curl_off_t filetime = -1;
     curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);

@Futaura
Copy link
Contributor Author

Futaura commented Aug 7, 2022

Sure - whatever you prefer. I just added it back more or less in the same way as it had been originally committed.

As suggested, move the Amiga SetComment() code into a separate
function and define a no-op macro which is used by other targets.
@Futaura
Copy link
Contributor Author

Futaura commented Aug 8, 2022

As suggested, I've moved the code into a function.

@bagder
Copy link
Member

bagder commented Aug 8, 2022

Thanks!

@bagder bagder closed this in 80e9eef Aug 8, 2022
@Futaura Futaura deleted the tool_amiga_setcomment branch August 8, 2022 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants