diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-02 09:07:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-02 09:07:15 +0300 |
commit | a14895149fad1724e0f4b4df1fd5834bddc4ead4 (patch) | |
tree | 15795172fe0f47c6ed06a707a520d506d768e564 /src/gmutil.c | |
parent | eae0ef64d071e2702fffc1d00f223124f8c6d8b4 (diff) |
Added a Gempub helper
`Gempub` opens and parses a Gempub archive and provides access to the contents in a common way.
Diffstat (limited to 'src/gmutil.c')
-rw-r--r-- | src/gmutil.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gmutil.c b/src/gmutil.c index 9f53ae87..a9d70fbb 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -438,7 +438,22 @@ iString *localFilePathFromUrl_String(const iString *d) { | |||
438 | return path; | 438 | return path; |
439 | } | 439 | } |
440 | 440 | ||
441 | const char *mediaTypeFromPath_String(const iString *path) { | 441 | const iString *findContainerArchive_Path(const iString *path) { |
442 | iBeginCollect(); | ||
443 | while (!isEmpty_String(path) && cmp_String(path, ".")) { | ||
444 | iString *dir = newRange_String(dirName_Path(path)); | ||
445 | if (endsWithCase_String(dir, ".zip") || | ||
446 | endsWithCase_String(dir, ".gpub")) { | ||
447 | iEndCollect(); | ||
448 | return collect_String(dir); | ||
449 | } | ||
450 | path = collect_String(dir); | ||
451 | } | ||
452 | iEndCollect(); | ||
453 | return NULL; | ||
454 | } | ||
455 | |||
456 | const char *mediaType_Path(const iString *path) { | ||
442 | if (endsWithCase_String(path, ".gmi") || endsWithCase_String(path, ".gemini")) { | 457 | if (endsWithCase_String(path, ".gmi") || endsWithCase_String(path, ".gemini")) { |
443 | return "text/gemini; charset=utf-8"; | 458 | return "text/gemini; charset=utf-8"; |
444 | } | 459 | } |