mirror of
https://github.com/FDOS/kernel.git
synced 2025-04-08 17:15:17 +02:00
Added a split boolean argument to dir_open so the trick with setting the
dir/filename separator to 0 can be avoided, and we don't need to calculate its location in split_path(). Without the trick many more char * path arguments in the kernel can become "const char *". git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1444 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
5c0be166ee
commit
d20b59ebe0
@ -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 == '\\')
|
||||
/* skip the path seperator */
|
||||
++dirname;
|
||||
/* don't continue if we're at the end */
|
||||
if (*dirname == '\0')
|
||||
break;
|
||||
|
||||
/* 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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user