fix redundant exists check and error-reporting problemss in directory-list

svn: r6038
This commit is contained in:
Matthew Flatt 2007-04-25 06:03:03 +00:00
parent 7c0ea5b79c
commit eeb65e6e53

View File

@ -4620,14 +4620,6 @@ static Scheme_Object *do_directory_list(int break_ok, int argc, Scheme_Object *a
} }
} }
if (filename && !scheme_directory_exists(filename)) {
if (break_ok)
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM,
"directory-list: could not open \"%q\"",
filename);
return NULL;
}
# ifdef USE_FINDFIRST # ifdef USE_FINDFIRST
if (!filename) if (!filename)
@ -4671,11 +4663,14 @@ static Scheme_Object *do_directory_list(int break_ok, int argc, Scheme_Object *a
hfile = FIND_FIRST(WIDE_PATH(pattern), &info); hfile = FIND_FIRST(WIDE_PATH(pattern), &info);
if (FIND_FAILED(hfile)) { if (FIND_FAILED(hfile)) {
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM, if (!filename)
"directory-list: could not open \"%q\" (%E)", return scheme_null;
filename, if (break_ok)
GetLastError()); scheme_raise_exn(MZEXN_FAIL_FILESYSTEM,
return scheme_null; "directory-list: could not open \"%q\" (%E)",
filename,
GetLastError());
return NULL;
} }
do { do {
@ -4711,8 +4706,16 @@ static Scheme_Object *do_directory_list(int break_ok, int argc, Scheme_Object *a
# else # else
dir = opendir(filename ? filename : "."); dir = opendir(filename ? filename : ".");
if (!dir) if (!dir) {
return scheme_null; if (!filename)
return scheme_null;
if (break_ok)
scheme_raise_exn(MZEXN_FAIL_FILESYSTEM,
"directory-list: could not open \"%q\" (%e)",
filename,
errno);
return NULL;
}
while ((e = readdir(dir))) { while ((e = readdir(dir))) {
# ifdef DIRENT_NO_NAMLEN # ifdef DIRENT_NO_NAMLEN