summaryrefslogtreecommitdiffstats
path: root/byterun/win32.c
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 /byterun/win32.c
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
Diffstat (limited to 'byterun/win32.c')
-rw-r--r--byterun/win32.c11
1 files changed, 9 insertions, 2 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;