diff options
author | Futaura <oliver@futaura.co.uk> | 2022-08-05 12:38:30 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-08-08 16:42:10 +0200 |
commit | 23c708cdc8cbecb31e56dd8436751b5f964869b1 (patch) | |
tree | 5e803ae9afabfe90597c484d5edc0a1337ec1a26 /lib/file.c | |
parent | ba2ccf368e0e0021697fe33a45a766e1f8532752 (diff) | |
download | curl-23c708cdc8cbecb31e56dd8436751b5f964869b1.tar.gz |
file: add handling of native AmigaOS paths
On AmigaOS 4.x, handle native absolute paths, whilst blocking relative
paths. Also allow unix style paths if feature enabled at link time.
Inspiration-from: Michael Trebilcock
Closes #9259
Diffstat (limited to 'lib/file.c')
-rw-r--r-- | lib/file.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/file.c b/lib/file.c index 15d7f3e57..d82d57b46 100644 --- a/lib/file.c +++ b/lib/file.c @@ -71,6 +71,8 @@ #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) #define DOS_FILESYSTEM 1 +#elif defined(__amigaos4__) +#define AMIGA_FILESYSTEM 1 #endif #ifdef OPEN_NEEDS_ARG3 @@ -196,8 +198,33 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done) return CURLE_URL_MALFORMAT; } + #ifdef AMIGA_FILESYSTEM + /* + * A leading slash in an AmigaDOS path denotes the parent + * directory, and hence we block this as it is relative. + * Absolute paths start with 'volumename:', so we check for + * this first. Failing that, we treat the path as a real unix + * path, but only if the application was compiled with -lunix. + */ + fd = -1; + file->path = real_path; + + if(real_path[0] == '/') { + extern int __unix_path_semantics; + if(strchr(real_path + 1, ':')) { + /* Amiga absolute path */ + fd = open_readonly(real_path + 1, O_RDONLY); + file->path++; + } + else if(__unix_path_semantics) { + /* -lunix fallback */ + fd = open_readonly(real_path, O_RDONLY); + } + } + #else fd = open_readonly(real_path, O_RDONLY); file->path = real_path; + #endif #endif file->freepath = real_path; /* free this when done */ |