Added __PHYSFS_addToLinkedStringList().

This commit is contained in:
Ryan C. Gordon 2002-07-23 07:48:08 +00:00
parent 5b55a52af7
commit 01567b3dcf
2 changed files with 50 additions and 1 deletions

View File

@ -1210,7 +1210,7 @@ int PHYSFS_isDirectory(const char *fname)
DirHandle *h = i->dirHandle; DirHandle *h = i->dirHandle;
if (__PHYSFS_verifySecurity(h, fname)) if (__PHYSFS_verifySecurity(h, fname))
{ {
if (!h->funcs->exists(h, fname)) if (!h->funcs->exists(h, fname)) /* !!! FIXME: Let archivers figure this out. */
__PHYSFS_setError(ERR_NO_SUCH_FILE); __PHYSFS_setError(ERR_NO_SUCH_FILE);
else else
{ {
@ -1461,5 +1461,41 @@ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle)
return(h->funcs->fileLength(h)); return(h->funcs->fileLength(h));
} /* PHYSFS_filelength */ } /* PHYSFS_filelength */
LinkedStringList *__PHYSFS_addToLinkedStringList(LinkedStringList *retval,
LinkedStringList **prev,
const char *str,
PHYSFS_sint32 len)
{
LinkedStringList *l;
l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
BAIL_IF_MACRO(l == NULL, ERR_OUT_OF_MEMORY, retval);
if (len < 0)
len = strlen(str);
l->str = (char *) malloc(len + 1);
if (l->str == NULL)
{
free(l);
BAIL_MACRO(ERR_OUT_OF_MEMORY, retval);
} /* if */
strncpy(l->str, str, len);
l->str[len] = '\0';
if (retval == NULL)
retval = l;
else
(*prev)->next = l;
*prev = l;
l->next = NULL;
return(retval);
} /* __PHYSFS_addToLinkedStringList */
/* end of physfs.c ... */ /* end of physfs.c ... */

View File

@ -166,6 +166,8 @@ typedef struct __PHYSFS_DIRFUNCTIONS__
/* /*
* Returns non-zero if filename is really a directory. * Returns non-zero if filename is really a directory.
* This filename is in platform-independent notation. * This filename is in platform-independent notation.
* Symlinks should be followed; if what the symlink points
* to is missing, or isn't a directory, then the retval is zero.
*/ */
int (*isDirectory)(DirHandle *r, const char *name); int (*isDirectory)(DirHandle *r, const char *name);
@ -317,6 +319,17 @@ char *__PHYSFS_convertToDependent(const char *prepend,
int __PHYSFS_verifySecurity(DirHandle *h, const char *fname); int __PHYSFS_verifySecurity(DirHandle *h, const char *fname);
/*
* Use this to build the list that your enumerate function should return.
* See zip.c for an example of proper use.
*/
LinkedStringList *__PHYSFS_addToLinkedStringList(LinkedStringList *retval,
LinkedStringList **prev,
const char *str,
PHYSFS_sint32 len);
/* These get used all over for lessening code clutter. */ /* These get used all over for lessening code clutter. */
#define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; } #define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; } #define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }