static char *cxr_findext( char *path, char const delim );
static char *cxr_findsep( char *path );
-static void cxr_stripext( char *path );
+static char *cxr_stripext( char *path );
static int cxr_path_is_abs( char const *path );
static char *cxr_filename( char *path );
return fsize;
}
+static int cxr_file_exists( const char *path )
+{
+ FILE *fp;
+ if( (fp=fopen( path, "rb" )) )
+ {
+ fclose(fp);
+ return 1;
+ }
+
+ return 0;
+}
+
static void *fs_disk_open_read( const char *path, int reserve_end, i64 *size )
{
FILE *f = fopen( path, "rb" );
if( f )
{
+ printf( "fs_open_read (%s)\n", path );
+
i64 fsize = cxr_file_size( f );
void *buf = malloc( fsize + reserve_end );
return ptr;
}
-static void cxr_stripext( char *path )
+static char *cxr_stripext( char *path )
{
- char *point, *start;
+ char *point, *start, *ret = NULL;
- // Skip folders
+ /* Skip any folders */
if( !(start = cxr_findsep( path )) )
{
start = path;
{
if( point > path )
{
- *(point-1) = 0x00;
+ ret = point-1;
+ *(ret) = 0x00;
}
}
+
+ return ret;
}
static void cxr_downlvl( char *path )
#endif
}
+static void cxr_lowercase( char *str )
+{
+ char *c = str;
+ while( *c )
+ {
+ int val = (int)*c;
+ if( val >= (int)'A' && val <= (int)'Z' )
+ {
+ val = (int)'a' + (val - (int)'A');
+ *c = (char)val;
+ }
+
+ c ++;
+ }
+}
+
+static void cxr_unixpath( char *path )
+{
+ char *c = path;
+ while( *c )
+ {
+ if( *c == '\\' )
+ *c = '/';
+
+ c ++;
+ }
+}
+
static char *cxr_str_clone( char const *str, int extra )
{
+ if( !str )
+ return NULL;
+
char *newstr = malloc(strlen(str)+1+extra);
strcpy( newstr, str );