API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
authorRyan C. Gordon <icculus@icculus.org>
Sun, 18 Sep 2005 21:44:42 +0000
changeset 754 e7cd7411eadf
parent 753 ad9d219dcb59
child 755 ccb7ed0547ef
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally requested directory back to the app.
CHANGELOG
archivers/dir.c
archivers/grp.c
archivers/hog.c
archivers/mix.c
archivers/mvl.c
archivers/qpak.c
archivers/wad.c
archivers/zip.c
physfs.c
physfs.h
physfs_internal.h
platform/macclassic.c
platform/os2.c
platform/pocketpc.c
platform/posix.c
platform/skeleton.c
platform/win32.c
--- a/CHANGELOG	Fri Sep 09 20:35:18 2005 +0000
+++ b/CHANGELOG	Sun Sep 18 21:44:42 2005 +0000
@@ -2,6 +2,10 @@
  * CHANGELOG.
  */
 
+09182005 - API BREAKAGE: PHYSFS_enumerateFilesCallback() now passes the
+           original directory name back to the app in the callback. This
+           API was only in 1.1.0, and wasn't promised to be stable at this
+           point. Please update your apps.
 09092005 - Some tweaks to PHYSFS_Allocator. Apparently configure.in doesn't
            work like I thought for version bumps, so it thinks 1.1.0 isn't
            binary compatible with 1.0...fixed, I think.
--- a/archivers/dir.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/dir.c	Sun Sep 18 21:44:42 2005 +0000
@@ -104,13 +104,14 @@
 
 
 static void DIR_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     char *d = __PHYSFS_platformCvtToDependent((char *)opaque, dname, NULL);
     if (d != NULL)
     {
-        __PHYSFS_platformEnumerateFiles(d, omitSymLinks, cb, callbackdata);
+        __PHYSFS_platformEnumerateFiles(d, omitSymLinks, cb,
+                                        origdir, callbackdata);
         allocator.Free(d);
     } /* if */
 } /* DIR_enumerateFiles */
--- a/archivers/grp.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/grp.c	Sun Sep 18 21:44:42 2005 +0000
@@ -295,8 +295,8 @@
 
 
 static void GRP_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     /* no directories in GRP files. */
     if (*dname != '\0')
@@ -307,7 +307,7 @@
         PHYSFS_uint32 i;
 
         for (i = 0; i < max; i++, entry++)
-            cb(callbackdata, entry->name);
+            cb(callbackdata, origdir, entry->name);
     } /* if */
 } /* GRP_enumerateFiles */
 
--- a/archivers/hog.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/hog.c	Sun Sep 18 21:44:42 2005 +0000
@@ -334,8 +334,8 @@
 
 
 static void HOG_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     /* no directories in HOG files. */
     if (*dname != '\0')
@@ -346,7 +346,7 @@
         PHYSFS_uint32 i;
 
         for (i = 0; i < max; i++, entry++)
-            cb(callbackdata, entry->name);
+            cb(callbackdata, origdir, entry->name);
     } /* if */
 } /* HOG_enumerateFiles */
 
--- a/archivers/mix.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/mix.c	Sun Sep 18 21:44:42 2005 +0000
@@ -288,8 +288,8 @@
 
 
 static void MIX_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     /* no directories in MIX files. */
     if (*dirname != '\0')
@@ -302,7 +302,7 @@
         for (i = 0; i < info->header.num_files; i++, entry++)
         {
             sprintf(buffer, "%X", entry->hash);
-            cb(callbackdata, buffer);
+            cb(callbackdata, origdir, buffer);
         } /* for */
     } /* if */
 } /* MIX_enumerateFiles */
--- a/archivers/mvl.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/mvl.c	Sun Sep 18 21:44:42 2005 +0000
@@ -291,8 +291,8 @@
 
 
 static void MVL_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     /* no directories in MVL files. */
     if (*dname != '\0')
@@ -303,7 +303,7 @@
         PHYSFS_uint32 i;
 
         for (i = 0; i < max; i++, entry++)
-            cb(callbackdata, entry->name);
+            cb(callbackdata, origdir, entry->name);
     } /* if */
 } /* MVL_enumerateFiles */
 
--- a/archivers/qpak.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/qpak.c	Sun Sep 18 21:44:42 2005 +0000
@@ -379,8 +379,8 @@
  * Moved to seperate function so we can use alloca then immediately throw
  *  away the allocated stack space...
  */
-static void doEnumCallback(PHYSFS_StringCallback cb, void *callbackdata,
-                           const char *str, PHYSFS_sint32 ln)
+static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata,
+                           const char *odir, const char *str, PHYSFS_sint32 ln)
 {
     char *newstr = alloca(ln + 1);
     if (newstr == NULL)
@@ -388,13 +388,13 @@
 
     memcpy(newstr, str, ln);
     newstr[ln] = '\0';
-    cb(callbackdata, newstr);
+    cb(callbackdata, odir, newstr);
 } /* doEnumCallback */
 
 
 static void QPAK_enumerateFiles(dvoid *opaque, const char *dname,
-                                int omitSymLinks, PHYSFS_StringCallback cb,
-                                void *callbackdata)
+                                int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                                const char *origdir, void *callbackdata)
 {
     QPAKinfo *info = ((QPAKinfo *) opaque);
     PHYSFS_sint32 dlen, dlen_inc, max, i;
@@ -421,7 +421,7 @@
         add = e + dlen_inc;
         ptr = strchr(add, '/');
         ln = (PHYSFS_sint32) ((ptr) ? ptr-add : strlen(add));
-        doEnumCallback(cb, callbackdata, add, ln);
+        doEnumCallback(cb, callbackdata, origdir, add, ln);
         ln += dlen_inc;  /* point past entry to children... */
 
         /* increment counter and skip children of subdirs... */
--- a/archivers/wad.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/wad.c	Sun Sep 18 21:44:42 2005 +0000
@@ -322,8 +322,8 @@
 
 
 static void WAD_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     WADinfo *info = ((WADinfo *) opaque);
     WADentry *entry = info->entries;
@@ -338,7 +338,7 @@
         {
             name = entry->name;
             if (strchr(name, '/') == NULL)
-                cb(callbackdata, name);
+                cb(callbackdata, origdir, name);
         } /* for */
     } /* if */
     else
--- a/archivers/zip.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/archivers/zip.c	Sun Sep 18 21:44:42 2005 +0000
@@ -1178,8 +1178,8 @@
  * Moved to seperate function so we can use alloca then immediately throw
  *  away the allocated stack space...
  */
-static void doEnumCallback(PHYSFS_StringCallback cb, void *callbackdata,
-                           const char *str, PHYSFS_sint32 ln)
+static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata,
+                           const char *odir, const char *str, PHYSFS_sint32 ln)
 {
     char *newstr = alloca(ln + 1);
     if (newstr == NULL)
@@ -1187,13 +1187,13 @@
 
     memcpy(newstr, str, ln);
     newstr[ln] = '\0';
-    cb(callbackdata, newstr);
+    cb(callbackdata, odir, newstr);
 } /* doEnumCallback */
 
 
 static void ZIP_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_StringCallback cb,
-                               void *callbackdata)
+                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
+                               const char *origdir, void *callbackdata)
 {
     ZIPinfo *info = ((ZIPinfo *) opaque);
     PHYSFS_sint32 dlen, dlen_inc, max, i;
@@ -1221,7 +1221,7 @@
             char *add = e + dlen_inc;
             char *ptr = strchr(add, '/');
             PHYSFS_sint32 ln = (PHYSFS_sint32) ((ptr) ? ptr-add : strlen(add));
-            doEnumCallback(cb, callbackdata, add, ln);
+            doEnumCallback(cb, callbackdata, origdir, add, ln);
             ln += dlen_inc;  /* point past entry to children... */
 
             /* increment counter and skip children of subdirs... */
--- a/physfs.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/physfs.c	Sun Sep 18 21:44:42 2005 +0000
@@ -1494,7 +1494,7 @@
 } /* locateInStringList */
 
 
-static void enumFilesCallback(void *data, const char *str)
+static void enumFilesCallback(void *data, const char *origdir, const char *str)
 {
     PHYSFS_uint32 pos;
     void *ptr;
@@ -1546,7 +1546,7 @@
 
 
 void PHYSFS_enumerateFilesCallback(const char *_fname,
-                                   PHYSFS_StringCallback callback,
+                                   PHYSFS_EnumFilesCallback callback,
                                    void *data)
 {
     DirHandle *i;
@@ -1570,13 +1570,14 @@
             char *end = strchr(ptr, '/');
             assert(end);  /* should always find a terminating '/'. */
             *end = '\0';  /* !!! FIXME: not safe in a callback... */
-            callback(data, ptr);
+            callback(data, _fname, ptr);
             *end = '/';   /* !!! FIXME: not safe in a callback... */
         } /* if */
 
         else if (verifyPath(i, &arcfname, 0))
         {
-            i->funcs->enumerateFiles(i->opaque,arcfname,noSyms,callback,data);
+            i->funcs->enumerateFiles(i->opaque, arcfname, noSyms,
+                                     callback, _fname, data);
         } /* else if */
     } /* for */
     __PHYSFS_platformReleaseMutex(stateLock);
--- a/physfs.h	Fri Sep 09 20:35:18 2005 +0000
+++ b/physfs.h	Sun Sep 18 21:44:42 2005 +0000
@@ -1978,14 +1978,15 @@
  *  be holding non recursive mutexes.
  */
 /* !!! FIXME: comment! */
-typedef void (*PHYSFS_StringCallback)(void *data, const char *);
+typedef void (*PHYSFS_StringCallback)(void *, const char *);
+typedef void (*PHYSFS_EnumFilesCallback)(void *, const char *, const char *);
 
 __EXPORT__ void PHYSFS_getCdRomDirsCallback(PHYSFS_StringCallback c, void *d);
 
 __EXPORT__ void PHYSFS_getSearchPathCallback(PHYSFS_StringCallback c, void *d);
 
 __EXPORT__ void PHYSFS_enumerateFilesCallback(const char *dir,
-                                              PHYSFS_StringCallback c,
+                                              PHYSFS_EnumFilesCallback c,
                                               void *d);
 
 
--- a/physfs_internal.h	Fri Sep 09 20:35:18 2005 +0000
+++ b/physfs_internal.h	Sun Sep 18 21:44:42 2005 +0000
@@ -995,7 +995,8 @@
     void (*enumerateFiles)(dvoid *opaque,
                             const char *dirname,
                             int omitSymLinks,
-                            PHYSFS_StringCallback callback,
+                            PHYSFS_EnumFilesCallback callback,
+                            const char *origdir,
                             void *callbackdata);
 
         /*
@@ -1568,7 +1569,8 @@
  */
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata);
 
 
--- a/platform/macclassic.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/macclassic.c	Sun Sep 18 21:44:42 2005 +0000
@@ -563,7 +563,8 @@
 /* returns int so we can use BAIL*MACRO... */
 static int macClassicEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
     UInt16 i;
@@ -618,7 +619,7 @@
         size = (size_t) str255[0];  /* (convert to ASCIZ string...) */
         memmove(&str255[0], &str255[1], size);
         str255[size] = '\0';
-        callback(callbackdata, (const char *) str255);
+        callback(callbackdata, origdir, (const char *) str255);
     } /* for */
 
     return(1);
@@ -627,10 +628,12 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
-    macClassicEnumerateFiles(dirname, omitSymLinks, callback, callbackdata);
+    macClassicEnumerateFiles(dirname, omitSymLinks, callback,
+                             origdir, callbackdata);
 } /* __PHYSFS_platformEnumerateFiles */
 
 
--- a/platform/os2.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/os2.c	Sun Sep 18 21:44:42 2005 +0000
@@ -398,7 +398,8 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
     char spec[CCHMAXPATH];
@@ -427,7 +428,7 @@
     while (count == 1)
     {
         if ((strcmp(fb.achName, ".") != 0) && (strcmp(fb.achName, "..") != 0))
-            callback(callbackdata, fb.achName);
+            callback(callbackdata, origdir, fb.achName);
 
         DosFindNext(hdir, &fb, sizeof (fb), &count);
     } /* while */
--- a/platform/pocketpc.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/pocketpc.c	Sun Sep 18 21:44:42 2005 +0000
@@ -296,7 +296,8 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
     HANDLE dir;
@@ -346,7 +347,7 @@
         if (str == NULL)
             break;
 
-        callback(callbackdata, str);
+        callback(callbackdata, origdir, str);
         allocator.Free(str);
     } while (FindNextFile(dir, &ent) != 0);
 
--- a/platform/posix.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/posix.c	Sun Sep 18 21:44:42 2005 +0000
@@ -227,7 +227,8 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
     DIR *dir;
@@ -286,7 +287,7 @@
                 continue;
         } /* if */
 
-        callback(callbackdata, ent->d_name);
+        callback(callbackdata, origdir, ent->d_name);
     } /* while */
 
     if (buf != NULL)
--- a/platform/skeleton.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/skeleton.c	Sun Sep 18 21:44:42 2005 +0000
@@ -106,7 +106,8 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
 } /* __PHYSFS_platformEnumerateFiles */
--- a/platform/win32.c	Fri Sep 09 20:35:18 2005 +0000
+++ b/platform/win32.c	Sun Sep 18 21:44:42 2005 +0000
@@ -440,7 +440,8 @@
 
 void __PHYSFS_platformEnumerateFiles(const char *dirname,
                                      int omitSymLinks,
-                                     PHYSFS_StringCallback callback,
+                                     PHYSFS_EnumFilesCallback callback,
+                                     const char *origdir,
                                      void *callbackdata)
 {
     HANDLE dir;
@@ -478,7 +479,7 @@
         if (strcmp(ent.cFileName, "..") == 0)
             continue;
 
-        callback(callbackdata, ent.cFileName);
+        callback(callbackdata, origdir, ent.cFileName);
     } while (FindNextFile(dir, &ent) != 0);
 
     FindClose(dir);