version 1.30, 2005/10/05 20:45:21
|
version 1.31, 2005/10/12 20:08:10
|
|
|
// Return the just the file name from the path into basename | // Return the just the file name from the path into basename |
char *System::extract_file_name(const char *fullpath, char *basename) | char *System::extract_file_name(const char *fullpath, char *basename) |
{ | { |
char *p; |
|
char buff[2048]; |
|
if (fullpath == NULL) | if (fullpath == NULL) |
{ | { |
basename[0] = '\0'; | basename[0] = '\0'; |
return basename; | return basename; |
} | } |
strcpy(buff, fullpath); |
|
for(p = buff + strlen(buff); p >= buff; p--) |
for (const char* p = fullpath + strlen(fullpath) - 1; p >= fullpath; p--) |
{ | { |
if (*p == '\\' || *p == '/') | if (*p == '\\' || *p == '/') |
{ | { |
|
|
return basename; | return basename; |
} | } |
} | } |
|
|
strcpy(basename, fullpath); | strcpy(basename, fullpath); |
return basename; | return basename; |
} | } |