diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 2002-12-13 05:54:05 -0800 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-12-17 02:17:16 +0000 |
commit | cd4e750ae15ad1c90d874c67a9960de086fdccf5 (patch) | |
tree | 80c7ac3165cf08aa37cc9f25202c086ecb25fd90 /os2 | |
parent | 803b07a779c719a9176a69ed7eb5685bb9f23042 (diff) | |
download | perl-cd4e750ae15ad1c90d874c67a9960de086fdccf5.tar.gz |
build
Message-ID: <20021213215404.GA2597@math.berkeley.edu>
p4raw-id: //depot/perl@18316
Diffstat (limited to 'os2')
-rw-r--r-- | os2/os2.c | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -2637,18 +2637,30 @@ my_tmpfile () #undef rmdir +/* EMX flavors do not tolerate trailing slashes. t/op/mkdir.t has many + trailing slashes, so we need to support this as well. */ + int my_rmdir (__const__ char *s) { - char buf[MAXPATHLEN]; + char b[MAXPATHLEN]; + char *buf = b; STRLEN l = strlen(s); + int rc; - if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX rmdir fails... */ + if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX mkdir fails... */ + if (l >= sizeof b) + New(1305, buf, l + 1, char); strcpy(buf,s); - buf[l - 1] = 0; + while (l > 1 && (s[l-1] == '/' || s[l-1] == '\\')) + l--; + buf[l] = 0; s = buf; } - return rmdir(s); + rc = rmdir(s); + if (b != buf) + Safefree(buf); + return rc; } #undef mkdir @@ -2656,15 +2668,24 @@ my_rmdir (__const__ char *s) int my_mkdir (__const__ char *s, long perm) { - char buf[MAXPATHLEN]; + char b[MAXPATHLEN]; + char *buf = b; STRLEN l = strlen(s); + int rc; if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX mkdir fails... */ + if (l >= sizeof b) + New(1305, buf, l + 1, char); strcpy(buf,s); - buf[l - 1] = 0; + while (l > 1 && (s[l-1] == '/' || s[l-1] == '\\')) + l--; + buf[l] = 0; s = buf; } - return mkdir(s, perm); + rc = mkdir(s, perm); + if (b != buf) + Safefree(buf); + return rc; } #undef flock |