Skip to content
Permalink
Browse files
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the ori…
…ginally

 requested directory back to the app.
  • Loading branch information
icculus committed Sep 18, 2005
1 parent 24ce834 commit 6e7e45cdaf11c3faf4ce3091633532b4a4f8d4f9
Showing with 68 additions and 51 deletions.
  1. +4 −0 CHANGELOG
  2. +4 −3 archivers/dir.c
  3. +3 −3 archivers/grp.c
  4. +3 −3 archivers/hog.c
  5. +3 −3 archivers/mix.c
  6. +3 −3 archivers/mvl.c
  7. +6 −6 archivers/qpak.c
  8. +3 −3 archivers/wad.c
  9. +6 −6 archivers/zip.c
  10. +5 −4 physfs.c
  11. +3 −2 physfs.h
  12. +4 −2 physfs_internal.h
  13. +7 −4 platform/macclassic.c
  14. +3 −2 platform/os2.c
  15. +3 −2 platform/pocketpc.c
  16. +3 −2 platform/posix.c
  17. +2 −1 platform/skeleton.c
  18. +3 −2 platform/win32.c
@@ -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.
@@ -104,13 +104,14 @@ static void *DIR_openArchive(const char *name, int forWriting)


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 */
@@ -295,8 +295,8 @@ static void *GRP_openArchive(const char *name, int forWriting)


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 @@ static void GRP_enumerateFiles(dvoid *opaque, const char *dname,
PHYSFS_uint32 i;

for (i = 0; i < max; i++, entry++)
cb(callbackdata, entry->name);
cb(callbackdata, origdir, entry->name);
} /* if */
} /* GRP_enumerateFiles */

@@ -334,8 +334,8 @@ static void *HOG_openArchive(const char *name, int forWriting)


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 @@ static void HOG_enumerateFiles(dvoid *opaque, const char *dname,
PHYSFS_uint32 i;

for (i = 0; i < max; i++, entry++)
cb(callbackdata, entry->name);
cb(callbackdata, origdir, entry->name);
} /* if */
} /* HOG_enumerateFiles */

@@ -288,8 +288,8 @@ static void *MIX_openArchive(const char *name, int forWriting)


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 @@ static void MIX_enumerateFiles(dvoid *opaque, const char *dname,
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 */
@@ -291,8 +291,8 @@ static void *MVL_openArchive(const char *name, int forWriting)


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 @@ static void MVL_enumerateFiles(dvoid *opaque, const char *dname,
PHYSFS_uint32 i;

for (i = 0; i < max; i++, entry++)
cb(callbackdata, entry->name);
cb(callbackdata, origdir, entry->name);
} /* if */
} /* MVL_enumerateFiles */

@@ -379,22 +379,22 @@ static PHYSFS_sint32 qpak_find_start_of_dir(QPAKinfo *info, const char *path,
* 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)
return;

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 @@ static void QPAK_enumerateFiles(dvoid *opaque, const char *dname,
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... */
@@ -322,8 +322,8 @@ static void *WAD_openArchive(const char *name, int forWriting)


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 @@ static void WAD_enumerateFiles(dvoid *opaque, const char *dname,
{
name = entry->name;
if (strchr(name, '/') == NULL)
cb(callbackdata, name);
cb(callbackdata, origdir, name);
} /* for */
} /* if */
else
@@ -1178,22 +1178,22 @@ static PHYSFS_sint32 zip_find_start_of_dir(ZIPinfo *info, const char *path,
* 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)
return;

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 @@ static void ZIP_enumerateFiles(dvoid *opaque, const char *dname,
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... */
@@ -1494,7 +1494,7 @@ static int locateInStringList(const char *str,
} /* 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 @@ char **PHYSFS_enumerateFiles(const char *path)


void PHYSFS_enumerateFilesCallback(const char *_fname,
PHYSFS_StringCallback callback,
PHYSFS_EnumFilesCallback callback,
void *data)
{
DirHandle *i;
@@ -1570,13 +1570,14 @@ void PHYSFS_enumerateFilesCallback(const char *_fname,
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);
@@ -1978,14 +1978,15 @@ __EXPORT__ const char *PHYSFS_getMountPoint(const char *dir);
* 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);


@@ -995,7 +995,8 @@ typedef struct
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_platformTimeslice(void);
*/
void __PHYSFS_platformEnumerateFiles(const char *dirname,
int omitSymLinks,
PHYSFS_StringCallback callback,
PHYSFS_EnumFilesCallback callback,
const char *origdir,
void *callbackdata);


@@ -563,7 +563,8 @@ void __PHYSFS_platformTimeslice(void)
/* 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 @@ static int macClassicEnumerateFiles(const char *dirname,
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 @@ static int macClassicEnumerateFiles(const char *dirname,

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 */


@@ -398,7 +398,8 @@ char *__PHYSFS_platformCvtToDependent(const char *prepend,

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 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname,
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 */
@@ -296,7 +296,8 @@ void __PHYSFS_platformTimeslice(void)

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 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname,
if (str == NULL)
break;

callback(callbackdata, str);
callback(callbackdata, origdir, str);
allocator.Free(str);
} while (FindNextFile(dir, &ent) != 0);

@@ -227,7 +227,8 @@ char *__PHYSFS_platformCvtToDependent(const char *prepend,

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 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname,
continue;
} /* if */

callback(callbackdata, ent->d_name);
callback(callbackdata, origdir, ent->d_name);
} /* while */

if (buf != NULL)
@@ -106,7 +106,8 @@ void __PHYSFS_platformTimeslice(void)

void __PHYSFS_platformEnumerateFiles(const char *dirname,
int omitSymLinks,
PHYSFS_StringCallback callback,
PHYSFS_EnumFilesCallback callback,
const char *origdir,
void *callbackdata)
{
} /* __PHYSFS_platformEnumerateFiles */
@@ -440,7 +440,8 @@ void __PHYSFS_platformTimeslice(void)

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 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname,
if (strcmp(ent.cFileName, "..") == 0)
continue;

callback(callbackdata, ent.cFileName);
callback(callbackdata, origdir, ent.cFileName);
} while (FindNextFile(dir, &ent) != 0);

FindClose(dir);

0 comments on commit 6e7e45c

Please sign in to comment.