dos_findfirst() now uses split_path(). The only thing that needed to be

added was the need to check for "d:\" paths which return DE_NFILES.
Also, findfirst("d:\nonexist\*.*",D_VOLID) should fail even if it actually
searches in d:\.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1441 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-06-13 03:44:50 +00:00
parent f7a9177b64
commit 60915d3cd0
4 changed files with 15 additions and 39 deletions

View File

@ -48,7 +48,7 @@ static BYTE *dosnamesRcsId =
returns number of characters in the directory component (up to the
last backslash, including d:) or negative if error
*/
int ParseDosName(const char *filename, BOOL bAllowWildcards)
int ParseDosName(const char *filename)
{
int nDirCnt;
const char *lpszLclDir, *lpszLclFile;
@ -76,14 +76,7 @@ int ParseDosName(const char *filename, BOOL bAllowWildcards)
++filename;
if (filename == lpszLclFile)
{
int err = DE_PATHNOTFND;
if (bAllowWildcards && *filename == '\0' &&
(nDirCnt == 3 || filename[-1] != '\\'))
/* D:\ or D:\DOS but not D:\DOS\ */
err = DE_NFILES;
return err;
}
return DE_PATHNOTFND;
return nDirCnt;
}

View File

@ -282,8 +282,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name)
{
REG f_node_ptr fnp;
REG dmatch *dmp = &sda_tmp_dm;
REG COUNT i;
char *fname;
/* printf("ff %Fs\n", name);*/
@ -294,14 +292,14 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name)
/* dirmatch structure and then for every find, we will open the */
/* current directory, do a seek and read. */
/* Parse out the file name */
i = ParseDosName(name, TRUE);
if (i < SUCCESS)
return i;
/*
printf("\nff %s", Tname);
printf("ff %s", fcbname);
*/
/* first: findfirst("D:\\") returns DE_NFILES */
if (name[3] == '\0')
return DE_NFILES;
/* Now open this directory so that we can read the */
/* fnode entry and do a match on it. */
if ((fnp = split_path(name, &fnode[0])) == NULL)
return DE_PATHNOTFND;
/* Now search through the directory to find the entry... */
@ -312,25 +310,11 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name)
/* RBIL: ignore ReaDONLY and ARCHIVE bits but DEVICE ignored too*/
/* For compatibility with bad search requests, only treat as */
/* volume search if only volume bit set, else ignore it. */
fname = &name[i];
if ((attr & ~(D_RDONLY | D_ARCHIVE | D_DEVICE)) == D_VOLID)
/* if ONLY label wanted redirect search to root dir */
i = 3;
dir_init_fnode(fnp, 0);
/* Now open this directory so that we can read the */
/* fnode entry and do a match on it. */
/* printf("dir_open %s\n", szDirName);*/
{
char tmp = name[i];
name[i] = '\0';
if ((fnp = dir_open(name, &fnode[0])) == NULL)
return DE_PATHNOTFND;
name[i] = tmp;
}
/* Now initialize the dirmatch structure. */
ConvertNameSZToName83(dmp->dm_name_pat, fname);
/* Now further initialize the dirmatch structure. */
dmp->dm_drive = name[0] - 'A';
dmp->dm_attr_srch = attr;

View File

@ -39,7 +39,6 @@ BYTE *RcsId = "$Id$";
/* */
STATIC f_node_ptr sft_to_fnode(int fd);
STATIC void fnode_to_sft(f_node_ptr fnp);
STATIC f_node_ptr split_path(char *, f_node_ptr fnp);
STATIC BOOL find_fname(f_node_ptr, int);
/* /// Added - Ron Cemer */
STATIC int merge_file_changes(f_node_ptr fnp, int collect);
@ -258,7 +257,7 @@ COUNT dos_close(COUNT fd)
f_node_ptr split_path(char * path, f_node_ptr fnp)
{
/* Start off by parsing out the components. */
int dirlength = ParseDosName(path, FALSE);
int dirlength = ParseDosName(path);
if (dirlength < SUCCESS)
return (f_node_ptr) 0;

View File

@ -130,7 +130,7 @@ VOID ASMCFUNC DosIdle_hlt(void);
#endif
/* dosnames.c */
int ParseDosName(const char *, BOOL);
int ParseDosName(const char *);
/* error.c */
VOID dump(void);
@ -171,7 +171,7 @@ CLUSTER dos_free(struct dpb FAR * dpbp);
BOOL dir_exists(char * path);
VOID dpb16to32(struct dpb FAR *dpbp);
VOID trim_path(BYTE FAR * s);
f_node_ptr split_path(char *, f_node_ptr fnp);
int dos_cd(char * PathName);