Author: ambs
Date: Mon Jan 9 13:50:28 2006
New Revision: 11026
Modified:
trunk/src/classes/os.pmc
trunk/t/pmc/os.t
Log:
Use _rmdir for directories under win32. Not tested yet :(
Modified: trunk/src/classes/os.pmc
==============================================================================
--- trunk/src/classes/os.pmc (original)
+++ trunk/src/classes/os.pmc Mon Jan 9 13:50:28 2006
@@ -120,14 +120,33 @@ C<path>.
*/
METHOD void rm(STRING *path) {
- int error;
+ struct stat info;
char *cpath = string_to_cstring(interpreter, path);
- error = remove(cpath);
- string_cstring_free(cpath);
+ int error = stat(cpath, &info);
if (error) {
char *errmsg = strerror(errno);
real_exception(interpreter, NULL, E_SystemError, errmsg);
}
+
+ if (S_ISDIR(info.st_mode)) {
+#ifdef WIN32
+ error = _rmdir(cpath);
+#else
+ error = rmdir(cpath);
+#endif
+ string_cstring_free(cpath);
+ if (error) {
+ char *errmsg = strerror(errno);
+ real_exception(interpreter, NULL, E_SystemError, errmsg);
+ }
+ } else {
+ error = remove(cpath);
+ string_cstring_free(cpath);
+ if (error) {
+ char *errmsg = strerror(errno);
+ real_exception(interpreter, NULL, E_SystemError, errmsg);
+ }
+ }
}
/*
Modified: trunk/t/pmc/os.t
==============================================================================
--- trunk/t/pmc/os.t (original)
+++ trunk/t/pmc/os.t Mon Jan 9 13:50:28 2006
@@ -125,9 +125,6 @@ OUT
}
-SKIP: {
- skip "remove for windows 32 is not working yet", 1 if $MSWin32;
-
# Test remove on a directory
mkdir "xpto" unless -d "xpto";
@@ -150,7 +147,6 @@ OUT
ok(!-d $xpto, "Test that rm removed the directory");
rmdir $xpto if -d $xpto; # this way next test doesn't fail if this one does
-}
# test stat
@@ -219,9 +215,6 @@ CODE
my $lstat;
-
-
-
SKIP: {
skip "lstat not available on Win 32 yet", 1 if $MSWin32;