summaryrefslogtreecommitdiff
path: root/lib/cdutils.cpp
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-10-29 16:52:24 -0700
committerPixel <pixel@nobis-crew.org>2009-10-29 16:52:24 -0700
commitaf7973b5b0bf0212415c8ca35cb88313226443a7 (patch)
tree5b9c663bf195270ad02ec054d15181512137a020 /lib/cdutils.cpp
parentc58b0339b6e94db44f675c95c97e2115456a26c0 (diff)
Adding the iterator over the dirutils objects...
Diffstat (limited to 'lib/cdutils.cpp')
-rw-r--r--lib/cdutils.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp
index d863927..607d42b 100644
--- a/lib/cdutils.cpp
+++ b/lib/cdutils.cpp
@@ -541,6 +541,57 @@ struct cdutils::DirEntry cdutils::find_dir_entry(struct DirEntry * dir, const St
return r;
}
+struct cdutils::DirEntry cdutils::get_next_dir_entry(struct DirEntry * dir, int * cursor, String & name) {
+ unsigned int ptr, size;
+ Uint8 * buffer;
+ struct DirEntry r = {0, 0, 0, 0, 0};
+ Uint32 Sector;
+
+ if (!(dir->Flags & 2)) {
+ return r;
+ }
+
+ size = from_LE32(dir->Size);
+ Sector = from_LE32(dir->Sector);
+
+ buffer = (Uint8 *) malloc(size);
+ read_data(buffer, size, GUESS, Sector);
+
+ dir = 0;
+
+ ptr = 0;
+ if (*cursor < size) {
+ dir = (struct DirEntry *) &(buffer[*cursor]);
+ if (!dir->R) {
+ (*cursor)++;
+ if (*cursor < size) {
+ dir = (struct DirEntry *) &(buffer[*cursor]);
+ } else {
+ dir = 0;
+ }
+ }
+ if (dir)
+ *cursor += dir->R;
+ }
+
+ if (dir && dir->R) {
+ if ((dir->N == 1) && (dir->id[0] == 0)) {
+ name = ".";
+ } else if ((dir->N == 1) && (dir->id[0] == 1)) {
+ name = "..";
+ } else {
+ name = String(dir->id, dir->N);
+ }
+
+ r = *dir;
+ } else {
+ name = "";
+ }
+
+ free(buffer);
+ return r;
+}
+
struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutils::DirEntry * dir, const String & name) {
unsigned int ptr, size;
Byte * buffer;