Skip to content

tool: reintroduce set file comment code for AmigaOS - #9258

Closed
Futaura wants to merge 2 commits into
curl:masterfrom
Futaura:tool_amiga_setcomment
Closed

Futaura wants to merge 2 commits into
curl:masterfrom
Futaura:tool_amiga_setcomment

Conversation

@Futaura

@Futaura Futaura commented Aug 6, 2022

Copy link
Copy Markdown
Contributor

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

@bagder bagder left a comment

Copy link
Copy Markdown
Member

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

Futaura commented Aug 7, 2022

Copy link
Copy Markdown
Contributor Author

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

Futaura commented Aug 8, 2022

Copy link
Copy Markdown
Contributor Author

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

@bagder

bagder commented Aug 8, 2022

Copy link
Copy Markdown
Member

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.

2 participants