=> 789847445dcc3f5938fdf5f9dab867c29b633fbc
[1mdiff --git a/include/the_Foundation/archive.h b/include/the_Foundation/archive.h[m [1mindex 68de5bd..b60f9f9 100644[m [1m--- a/include/the_Foundation/archive.h[m [1m+++ b/include/the_Foundation/archive.h[m [36m@@ -24,6 +24,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m [m #include "block.h"[m #include "string.h"[m [32m+[m[32m#include "stringset.h"[m #include "time.h"[m [m #if defined (iHaveZlib)[m [36m@@ -53,6 +54,9 @@[m [mvoid close_Archive (iArchive *);[m [m iBool isOpen_Archive (const iArchive *);[m size_t numEntries_Archive (const iArchive *);[m [32m+[m[32miBool isDirectory_Archive (const iArchive *, const iString *path);[m [32m+[m [32m+[m[32miStringSet * listDirectory_Archive (const iArchive *, const iString *dirPath);[m [m const iArchiveEntry * entry_Archive (const iArchive *, const iString *path);[m const iArchiveEntry * entryAt_Archive (const iArchive *, size_t index);[m [1mdiff --git a/src/archive.c b/src/archive.c[m [1mindex 4880e44..a4d11c0 100644[m [1m--- a/src/archive.c[m [1m+++ b/src/archive.c[m [36m@@ -24,6 +24,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include "the_Foundation/array.h"[m #include "the_Foundation/buffer.h"[m #include "the_Foundation/file.h"[m [32m+[m[32m#include "the_Foundation/path.h"[m #include "the_Foundation/sortedarray.h"[m [m /* Marker signatures. */[m [36m@@ -418,6 +419,54 @@[m [msize_t numEntries_Archive(const iArchive *d) {[m return size_SortedArray(d->entries);[m }[m [m [32m+[m[32miBool isDirectory_Archive(const iArchive *d, const iString *path) {[m [32m+[m[32m if (isEmpty_String(path)) {[m [32m+[m[32m return iTrue; /* root */[m [32m+[m[32m }[m [32m+[m[32m size_t pos = iInvalidPos;[m [32m+[m[32m iArchiveEntry entry;[m [32m+[m[32m initCopy_String(&entry.path, path);[m [32m+[m[32m locate_SortedArray(d->entries, &entry, &pos);[m [32m+[m[32m deinit_String(&entry.path);[m [32m+[m[32m if (pos != iInvalidPos) {[m [32m+[m[32m const iArchiveEntry *match = constAt_SortedArray(d->entries, pos);[m [32m+[m[32m if (size_String(&match->path) > size_String(path)) {[m [32m+[m[32m return startsWith_String(&match->path, cstr_String(path));[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m return iFalse;[m [32m+[m[32m}[m [32m+[m [32m+[m[32miStringSet *listDirectory_Archive(const iArchive *d, const iString *dirPath) {[m [32m+[m[32m iStringSet *paths = new_StringSet();[m [32m+[m[32m iString path;[m [32m+[m[32m init_String(&path);[m [32m+[m[32m iConstForEach(Array, i, &d->entries->values) {[m [32m+[m[32m const iArchiveEntry *entry = i.value;[m [32m+[m[32m iRangecc entryDir = dirName_Path(&entry->path);[m [32m+[m[32m if (!isEmpty_Range(&entryDir)) {[m [32m+[m[32m entryDir.end++; /* include the slash */[m [32m+[m[32m }[m [32m+[m[32m if (!cmp_Rangecc(entryDir, cstr_String(dirPath))) {[m [32m+[m[32m insert_StringSet(paths, &entry->path);[m [32m+[m[32m }[m [32m+[m[32m else if (startsWith_Rangecc(entryDir, cstr_String(dirPath))) {[m [32m+[m[32m /* A subdirectory. */[m [32m+[m[32m size_t nextSlash = indexOfCStrFrom_String(&entry->path, "/", size_String(dirPath));[m [32m+[m[32m if (nextSlash != iInvalidPos) {[m [32m+[m[32m set_String(&path, dirPath);[m [32m+[m[32m appendRange_String([m [32m+[m[32m &path,[m [32m+[m[32m (iRangecc){ constBegin_String(&entry->path) + size_String(dirPath),[m [32m+[m[32m constBegin_String(&entry->path) + nextSlash + 1 });[m [32m+[m[32m insert_StringSet(paths, &path);[m [32m+[m[32m }[m[41m [m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m deinit_String(&path);[m [32m+[m[32m return paths;[m [32m+[m[32m}[m [32m+[m const iArchiveEntry *entryAt_Archive(const iArchive *d, size_t index) {[m if (index >= size_SortedArray(d->entries)) {[m return NULL;[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).