Author: ambs
Date: Mon Jan  9 14:12:15 2006
New Revision: 11028

Modified:
   trunk/src/classes/os.pmc
   trunk/t/pmc/os.t
Log:
mkdir and cwd on windows? Just ask particle :-)


Modified: trunk/src/classes/os.pmc
==============================================================================
--- trunk/src/classes/os.pmc    (original)
+++ trunk/src/classes/os.pmc    Mon Jan  9 14:12:15 2006
@@ -60,13 +60,16 @@ Returns the current working directory.
 */
 
     METHOD STRING* cwd() {
-#ifndef _MSC_VER
         char * cwd;
+#ifdef WIN32
+        cwd = _getcwd(NULL, 0);
+#else
 #ifdef PATH_MAX
         cwd = getcwd(NULL, PATH_MAX+1);
 #else 
         cwd = getcwd(NULL, 0);
 #endif
+#endif
         if (cwd) {
             STRING *scwd;
             scwd = string_from_cstring(interpreter, cwd, strlen(cwd));
@@ -77,10 +80,6 @@ Returns the current working directory.
             real_exception(interpreter, NULL, E_SystemError, errmsg);
             return NULL;
         }
-#else
-        internal_exception(UNIMPLEMENTED, "Win32 is not POSIX. Need win32 
developer!");
-        return NULL;
-#endif
     }
 
 /*
@@ -94,18 +93,18 @@ Changes the current working directory to
 */
 
     METHOD void chdir(STRING *path) {
-#ifndef _MSC_VER
         int error;
         char *cpath = string_to_cstring(interpreter, path);
+#ifdef WIN32
+        error = _chdir(cpath);
+#else
         error = chdir(cpath);
+#endif
         string_cstring_free(cpath);
         if (error) {
             char *errmsg = strerror(errno);
             real_exception(interpreter, NULL, E_SystemError, errmsg);
         }
-#else
-        internal_exception(UNIMPLEMENTED, "Win32 is not POSIX. Need win32 
developer!");
-#endif
     }
 
 /*
@@ -160,12 +159,11 @@ Creates a directory specified by C<path>
 */
 
     METHOD void mkdir(STRING *path, INTVAL mode) {
-#ifndef _MSC_VER
         int error;
         char *cpath = string_to_cstring(interpreter, path);
         /* should we validate mode? */
 #ifdef WIN32
-        error = mkdir(cpath);
+        error = _mkdir(cpath);
 #else
         error = mkdir(cpath, mode);
 #endif
@@ -174,9 +172,6 @@ Creates a directory specified by C<path>
             char *errmsg = strerror(errno);
             real_exception(interpreter, NULL, E_SystemError, errmsg);
         }
-#else
-        internal_exception(UNIMPLEMENTED, "Win32 is not POSIX. Need win32 
developer!");
-#endif
     }
 
 /*

Modified: trunk/t/pmc/os.t
==============================================================================
--- trunk/t/pmc/os.t    (original)
+++ trunk/t/pmc/os.t    Mon Jan  9 14:12:15 2006
@@ -36,10 +36,7 @@ END {
 
 # test 'cwd'
 my $cwd = getcwd;
-SKIP: {
-  skip "cwd not available yet under windows", 1 if $MSWin32;
-
-  pir_output_is(<<'CODE', <<"OUT", "Test cwd");
+pir_output_is(<<'CODE', <<"OUT", "Test cwd");
 .sub main :main
         $P1 = new .OS
         $S1 = $P1."cwd"()
@@ -50,7 +47,6 @@ SKIP: {
 CODE
 $cwd
 OUT
-}
 
 
 #  TEST chdir
@@ -58,10 +54,7 @@ chdir "src";
 my $upcwd = getcwd;
 chdir "..";
 
-SKIP: {
-  skip "cwd and chdir not available on Win 32 yet", 1 if $MSWin32;
-
-  pir_output_is(<<'CODE', <<"OUT", "Test chdir");
+pir_output_is(<<'CODE', <<"OUT", "Test chdir");
 .sub main :main
         $P1 = new .OS
 
@@ -85,7 +78,7 @@ CODE
 $upcwd
 $cwd
 OUT
-}
+
 
 # Test mkdir
 
@@ -93,10 +86,7 @@ my $xpto = $upcwd;
 $xpto =~ s/src([\/\\]?)$/xpto$1/;
 
 
-SKIP: {
-  skip "cwd, mkdir and chdir not available on Win 32 yet", 1 if $MSWin32;
-
-  pir_output_is(<<'CODE', <<"OUT", "Test mkdir");
+pir_output_is(<<'CODE', <<"OUT", "Test mkdir");
 .sub main :main
         $P1 = new .OS
 
@@ -122,7 +112,7 @@ CODE
 $xpto
 $cwd
 OUT
-}
+
 
 
 # Test remove on a directory

Reply via email to