diff options
-rw-r--r-- | byterun/win32.c | 11 | ||||
-rw-r--r-- | otherlibs/win32unix/unix.ml | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/byterun/win32.c b/byterun/win32.c index 7f6459f8e..df3aee683 100644 --- a/byterun/win32.c +++ b/byterun/win32.c @@ -343,6 +343,7 @@ CAMLexport void caml_expand_command_line(int * argcp, char *** argvp) int caml_read_directory(char * dirname, struct ext_table * contents) { + int dirnamelen; char * template; #if _MSC_VER <= 1200 int h; @@ -352,9 +353,15 @@ int caml_read_directory(char * dirname, struct ext_table * contents) struct _finddata_t fileinfo; char * p; - template = caml_stat_alloc(strlen(dirname) + 5); + dirnamelen = strlen(dirname); + template = caml_stat_alloc(dirnamelen + 5); strcpy(template, dirname); - strcat(template, "\\*.*"); + switch (dirname[dirnamelen - 1]) { + case '/': case '\\': case ':': + strcat(template, "*.*"); break; + default: + strcat(template, "\\*.*"); + } h = _findfirst(template, &fileinfo); caml_stat_free(template); if (h == -1) return errno == ENOENT ? 0 : -1; diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml index acb12d695..2ae4a61a0 100644 --- a/otherlibs/win32unix/unix.ml +++ b/otherlibs/win32unix/unix.ml @@ -326,7 +326,7 @@ external findnext : int -> string= "win_findnext" let opendir dirname = try - let (first_entry, handle) = findfirst (dirname ^ "\\*.*") in + let (first_entry, handle) = findfirst (Filename.concat dirname "*.*") in { dirname = dirname; handle = handle; entry_read = Dir_read first_entry } with End_of_file -> { dirname = dirname; handle = 0; entry_read = Dir_empty } |