FIXME removal.

This commit is contained in:
Ryan C. Gordon 2002-05-21 11:29:00 +00:00
parent 996aa0013a
commit 769b2a5464
4 changed files with 71 additions and 47 deletions

View File

@ -234,7 +234,7 @@ static int DIR_isSymLink(DirHandle *h, const char *name)
char *f = __PHYSFS_platformCvtToDependent((char *)(h->opaque), name, NULL);
int retval;
BAIL_IF_MACRO(f == NULL, NULL, 0); /* !!! might be a problem. */
BAIL_IF_MACRO(f == NULL, NULL, 0);
retval = __PHYSFS_platformIsSymLink(f);
free(f);
return(retval);

View File

@ -350,7 +350,7 @@ static char *calculateBaseDir(const char *argv0)
p = strstr(p + 1, dirsep);
} /* while */
size = (size_t) (ptr - argv0); /* !!! is this portable? */
size = (size_t) (ptr - argv0);
retval = (char *) malloc(size + 1);
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
memcpy(retval, argv0, size);
@ -1202,8 +1202,6 @@ int PHYSFS_isSymbolicLink(const char *fname)
} /* if */
} /* if */
} /* for */
/* !!! FIXME: setError ERR_FILE_NOT_FOUND? */
__PHYSFS_platformReleaseMutex(stateLock);
return(0);

View File

@ -978,12 +978,6 @@ __EXPORT__ PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val);
*/
__EXPORT__ PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val);
#if 0 /* !!! FIXME: add this? */
#undef __EXPORT__
#endif
#ifdef __cplusplus
}
#endif

View File

@ -100,7 +100,8 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
add_it = 1;
else if ( strcmp( mntbufp[ii].f_fstypename, "cd9660") == 0 )
add_it = 1;
/* !!! other mount types? */
/* add other mount types here */
if (add_it)
{
@ -147,7 +148,8 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
int add_it = 0;
if (strcmp(ent->mnt_type, "iso9660") == 0)
add_it = 1;
/* !!! other mount types? */
/* add other mount types here */
if (add_it)
{
@ -190,52 +192,82 @@ static char *copyEnvironmentVariable(const char *varname)
} /* copyEnvironmentVariable */
/* !!! this is ugly. */
/*
* See where program (bin) resides in the $PATH specified by (envr).
* returns a copy of the first element in envr that contains it, or NULL
* if it doesn't exist or there were other problems. PHYSFS_SetError() is
* called if we have a problem.
*
* (envr) will be scribbled over, and you are expected to free() the
* return value when you're done with it.
*/
static char *findBinaryInPath(const char *bin, char *envr)
{
size_t alloc_size = 0;
char *exe = NULL;
char *start = envr;
char *ptr;
BAIL_IF_MACRO(bin == NULL, ERR_INVALID_ARGUMENT, NULL);
BAIL_IF_MACRO(envr == NULL, ERR_INVALID_ARGUMENT, NULL);
do
{
size_t size;
ptr = strchr(start, ':'); /* find next $PATH separator. */
if (ptr)
*ptr = '\0';
size = strlen(start) + strlen(bin) + 2;
if (size > alloc_size)
{
char *x = (char *) realloc(exe, size);
if (x == NULL)
{
if (exe != NULL)
free(exe);
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
} /* if */
alloc_size = size;
exe = x;
} /* if */
/* build full binary path... */
strcpy(exe, start);
if (exe[strlen(exe) - 1] != '/')
strcat(exe, "/");
strcat(exe, bin);
if (access(exe, X_OK) == 0) /* Exists as executable? We're done. */
{
strcpy(exe, start); /* i'm lazy. piss off. */
return(exe);
} /* if */
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
if (exe != NULL)
free(exe);
return(NULL); /* doesn't exist in path. */
} /* findBinaryInPath */
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
/* If there isn't a path on argv0, then look through the $PATH for it. */
char *retval = NULL;
char *retval;
char *envr;
char *start;
char *ptr;
char *exe;
if (strchr(argv0, '/') != NULL) /* default behaviour can handle this. */
return(NULL);
envr = copyEnvironmentVariable("PATH");
BAIL_IF_MACRO(!envr, NULL, NULL);
start = envr;
do
{
ptr = strchr(start, ':');
if (ptr)
*ptr = '\0';
exe = (char *) malloc(strlen(start) + strlen(argv0) + 2);
if (!exe)
{
free(envr);
BAIL_IF_MACRO(1, ERR_OUT_OF_MEMORY, NULL);
} /* if */
strcpy(exe, start);
if (exe[strlen(exe) - 1] != '/')
strcat(exe, "/");
strcat(exe, argv0);
if (access(exe, X_OK) != 0)
free(exe);
else
{
retval = exe;
strcpy(retval, start); /* i'm lazy. piss off. */
break;
} /* else */
start = ptr + 1;
} while (ptr != NULL);
retval = findBinaryInPath(argv0, envr);
free(envr);
return(retval);
} /* __PHYSFS_platformCalcBaseDir */