aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxcd
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-28 18:46:06 +0100
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-28 18:46:06 +0100
commit7186b911cc461dbdad9307afd8901be118e20893 (patch)
treed4fe73b268c92345922625329e6a5f43ce914254 /libpsn00b/psxcd
parenta75b3fa4b1a1b882c33f533645ddae75c09dd697 (diff)
downloadpsn00bsdk-7186b911cc461dbdad9307afd8901be118e20893.tar.gz
CMake fixes, psxcd and printf/scanf improvements
Diffstat (limited to 'libpsn00b/psxcd')
-rw-r--r--libpsn00b/psxcd/isofs.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c
index 40a40af..29bbb76 100644
--- a/libpsn00b/psxcd/isofs.c
+++ b/libpsn00b/psxcd/isofs.c
@@ -10,6 +10,9 @@
// Uncommend to enable debug output
//#define DEBUG
+#define DEFAULT_PATH_SEP '\\'
+#define IS_PATH_SEP(ch) (((ch) == '/') || ((ch) == '\\'))
+
typedef struct _CdlDIR_INT
{
u_long _pos;
@@ -374,7 +377,7 @@ static char* resolve_pathtable_path(int entry, char *rbuff)
rbuff -= tbl_entry.nameLength;
memcpy(rbuff, namebuff, tbl_entry.nameLength);
rbuff--;
- *rbuff = '\\';
+ *rbuff = DEFAULT_PATH_SEP;
// Parse to the parent
entry = tbl_entry.dirLevel;
@@ -431,12 +434,15 @@ static int find_dir_entry(const char *name, ISO_DIR_ENTRY *dirent)
static char* get_pathname(char *path, const char *filename)
{
- char *c;
- c = strrchr(filename, '\\');
+ char *c = 0;
+ for (char *i = filename; *i; i++) {
+ if (IS_PATH_SEP(*i))
+ c = i;
+ }
if(( c == filename ) || ( !c ))
{
- path[0] = '\\';
+ path[0] = DEFAULT_PATH_SEP;
path[1] = 0;
return NULL;
}
@@ -447,11 +453,17 @@ static char* get_pathname(char *path, const char *filename)
static char* get_filename(char *name, const char *filename)
{
- char *c;
- c = strrchr(filename, '\\');
+ char *c = 0;
+ for (char *i = filename; *i; i++) {
+ if (IS_PATH_SEP(*i))
+ c = i;
+ }
- if(( c == filename ) || ( !c ))
- {
+ if (!c) {
+ strcpy(name, filename);
+ return name;
+ }
+ if (c == filename) {
strcpy(name, filename+1);
return name;
}