tool: reintroduce set file comment code for AmigaOS#9258
Closed
Futaura wants to merge 2 commits intocurl:masterfrom
Closed
tool: reintroduce set file comment code for AmigaOS#9258Futaura wants to merge 2 commits intocurl:masterfrom
Futaura wants to merge 2 commits intocurl:masterfrom
Conversation
bagder
reviewed
Aug 6, 2022
Member
bagder
left a comment
There was a problem hiding this comment.
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);
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.
Contributor
Author
|
As suggested, I've moved the code into a function. |
bagder
approved these changes
Aug 8, 2022
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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