X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdired-msw.c;h=791ed06a91c5c192dc4253eceb6a0068216c422f;hb=1d0f965ba499c40eb5b24415c62ec0dc2b0b8ff7;hp=f717c650903e4935e15a2e9fc98fc1aa3a61db18;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git.1 diff --git a/src/dired-msw.c b/src/dired-msw.c index f717c65..791ed06 100644 --- a/src/dired-msw.c +++ b/src/dired-msw.c @@ -76,11 +76,9 @@ Boston, MA 02111-1307, USA. */ #include "regex.h" #include "sysdir.h" -#include "sysfile.h" #include "sysproc.h" +#include "sysfile.h" -#include -#include #include #include /* To make nt.h happy */ @@ -92,7 +90,7 @@ Boston, MA 02111-1307, USA. */ static int mswindows_ls_sort_case_insensitive; -static int mswindows_ls_round_file_size; +static Fixnum mswindows_ls_round_file_size; Lisp_Object Qmswindows_insert_directory; @@ -175,6 +173,7 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, int findex, len; char win32pattern[MAXNAMLEN+3]; HANDLE fh; + int errm; /* * Much of the following code and comments were taken from dired.c. @@ -189,7 +188,7 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, /* PATTERN might be a flawed regular expression. Rather than catching and signalling our own errors, we just call compile_pattern to do the work for us. */ - bufp = compile_pattern (pattern, 0, 0, 0, ERROR_ME); + bufp = compile_pattern (pattern, 0, Qnil, 0, ERROR_ME); } /* Now *bufp is the compiled form of PATTERN; don't call anything which might compile a new regexp until we're done with the loop! */ @@ -210,12 +209,14 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, /* * Here, we use FindFirstFile()/FindNextFile() instead of opendir(), - * stat(), & friends, because stat() is VERY expensive in terms of - * time. Hence, we take the time to write complicated Win32-specific - * code, instead of simple Unix-style stuff. + * xemacs_stat(), & friends, because xemacs_stat() is VERY expensive in + * terms of time. Hence, we take the time to write complicated + * Win32-specific code, instead of simple Unix-style stuff. */ findex = 0; fh = INVALID_HANDLE_VALUE; + errm = SetErrorMode (SEM_FAILCRITICALERRORS + | SEM_NOOPENFILEERRORBOX); while (1) { @@ -228,6 +229,7 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, fh = FindFirstFile(win32pattern, &files[findex]); if (fh == INVALID_HANDLE_VALUE) { + SetErrorMode (errm); report_file_error ("Opening directory", list1(build_string(dirfile))); } @@ -241,6 +243,7 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, break; } FindClose(fh); + SetErrorMode (errm); report_file_error ("Reading directory", list1(build_string(dirfile))); } @@ -279,6 +282,8 @@ mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern, *nfiles = findex; break; } + + SetErrorMode (errm); return (files); } @@ -319,14 +324,14 @@ mswindows_format_file (WIN32_FIND_DATA *file, char *buf, int display_size, cptr[1] = cptr[4] = cptr[7] = 'w'; } if ((file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || - len > 4 && - (_stricmp(&file->cFileName[len - 4], ".exe") == 0 - || _stricmp(&file->cFileName[len - 4], ".com") == 0 - || _stricmp(&file->cFileName[len - 4], ".bat") == 0 + (len > 4 && + (_stricmp(&file->cFileName[len - 4], ".exe") == 0 + || _stricmp(&file->cFileName[len - 4], ".com") == 0 + || _stricmp(&file->cFileName[len - 4], ".bat") == 0 #if 0 - || _stricmp(&file->cFileName[len - 4], ".pif") == 0 + || _stricmp(&file->cFileName[len - 4], ".pif") == 0 #endif - )) + ))) { cptr[2] = cptr[5] = cptr[8] = 'x'; } else { @@ -430,9 +435,8 @@ switches do not contain `d', so that a full listing is expected. (file, switches, wildcard, full_directory_p)) { Lisp_Object result, handler, wildpat, fns, basename; - char *filename; char *switchstr; - int len, nfiles, i; + int nfiles, i; int hide_system, hide_dot, reverse, display_size; WIN32_FIND_DATA *files, **sorted_files; enum mswindows_sortby sort_by; @@ -497,28 +501,11 @@ switches do not contain `d', so that a full listing is expected. } } - /* - * Sometimes we get ".../foo* /" as FILE (without the space). - * While the shell and `ls' don't mind, we certainly do, - * because it makes us think there is no wildcard, only a - * directory name. - */ - if (!NILP(Fstring_match(build_string("[[?*]"), file, Qnil, Qnil))) - { - wildcard = Qt; - filename = XSTRING_DATA(file); - len = strlen(filename); - if (len > 0 && (filename[len - 1] == '\\' || - filename[len - 1] == '/')) - { - filename[len - 1] = '\0'; - } - file = build_string(filename); - } if (!NILP(wildcard)) { Lisp_Object newfile; + file = Fdirectory_file_name (file); basename = Ffile_name_nondirectory(file); fns = intern("wildcard-to-regexp"); wildpat = call1(fns, basename); @@ -639,7 +626,7 @@ syms_of_dired_mswindows (void) void vars_of_dired_mswindows (void) { - DEFVAR_BOOL ("mswindows-ls-sort-case-insensitive", &mswindows_ls_sort_case_insensitive, /* + DEFVAR_BOOL ("mswindows-ls-sort-case-insensitive", &mswindows_ls_sort_case_insensitive /* *Non-nil means filenames are sorted in a case-insensitive fashion. Nil means filenames are sorted in a case-sensitive fashion, just like Unix. */ );