diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 1be57c1..687963a 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -58,7 +58,7 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_cluster = fnp->f_dmp->dm_dircluster = dirstart; } -f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp) +f_node_ptr dir_open(register const char *dirname, BOOL split, f_node_ptr fnp) { int i; char *fcbname; @@ -87,18 +87,19 @@ f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp) fcbname = fnp->f_dmp->dm_name_pat; while(*dirname != '\0') { - /* skip all path seperators */ - while (*dirname == '\\') - ++dirname; - /* don't continue if we're at the end */ - if (*dirname == '\0') - break; + /* skip the path seperator */ + ++dirname; /* Convert the name into an absolute name for */ /* comparison... */ dirname = ConvertNameSZToName83(fcbname, dirname); + /* do not continue if we split the filename off and are */ + /* at the end */ + if (split && *dirname == '\0') + break; + /* Now search through the directory to */ /* find the entry... */ i = FALSE; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8fbe40b..d3d8a8c 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -254,18 +254,10 @@ COUNT dos_close(COUNT fd) /* */ /* split a path into it's component directory and file name */ /* */ -f_node_ptr split_path(char * path, f_node_ptr fnp) +f_node_ptr split_path(const char * path, f_node_ptr fnp) { - /* Start off by parsing out the components. */ - int i = 2, dirlength = 3; - - /* Now see how long a directory component we have. */ - while (path[i]) - if (path[i++] == '\\') - dirlength = i; - /* check if the path ends in a backslash */ - if (path[dirlength] == '\0') + if (path[strlen(path) - 1] == '\\') return (f_node_ptr) 0; /* 11/29/99 jt @@ -289,18 +281,7 @@ f_node_ptr split_path(char * path, f_node_ptr fnp) #endif /* Translate the path into a useful pointer */ - { - char tmp = path[dirlength]; - path[dirlength] = '\0'; - fnp = dir_open(path, fnp); - path[dirlength] = tmp; - } - - /* Extract the 8.3 filename from the path */ - if (fnp) - ConvertNameSZToName83(fnp->f_dmp->dm_name_pat, &path[dirlength]); - - return fnp; + return dir_open(path, TRUE, fnp); } /* checks whether directory part of path exists */ @@ -498,7 +479,7 @@ COUNT dos_rmdir(BYTE * path) /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ - fnp = dir_open(path, &fnode[0]); + fnp = dir_open(path, FALSE, &fnode[0]); if (fnp == NULL) return DE_PATHNOTFND; @@ -1539,7 +1520,7 @@ int dos_cd(char * PathName) return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ - if ((fnp = dir_open(PathName, &fnode[0])) == NULL) + if ((fnp = dir_open(PathName, FALSE, &fnode[0])) == NULL) return DE_PATHNOTFND; /* problem: RBIL table 01643 does not give a FAT32 field for the diff --git a/kernel/proto.h b/kernel/proto.h index 682f1cd..fa93118 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -136,7 +136,7 @@ VOID fatal(BYTE * err_msg); /* fatdir.c */ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); -f_node_ptr dir_open(const char *dirname, f_node_ptr fnp); +f_node_ptr dir_open(const char *dirname, BOOL split, f_node_ptr fnp); COUNT dir_read(REG f_node_ptr fnp); BOOL dir_write_update(REG f_node_ptr fnp, BOOL update); #define dir_write(fnp) dir_write_update(fnp, FALSE) @@ -168,7 +168,7 @@ CLUSTER dos_free(struct dpb FAR * dpbp); BOOL dir_exists(char * path); VOID dpb16to32(struct dpb FAR *dpbp); -f_node_ptr split_path(char *, f_node_ptr fnp); +f_node_ptr split_path(const char *, f_node_ptr fnp); int dos_cd(char * PathName);