summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2007-02-25 14:38:11 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2007-02-25 14:38:11 +0000
commitefbf67e517d799bb62454de08617dfec7848a36c (patch)
treef66f15313e271211ba3bc0d54f1a70d8ca640644
parent4fd5cfb53969bb64c7156491637549458d25b75e (diff)
Tentative fix for PR#3927. To be tested.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7921 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--byterun/win32.c11
-rw-r--r--otherlibs/win32unix/unix.ml2
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 }