Win32OperatingSystem.st
branchjv
changeset 18022 f23232c2eaef
parent 18011 deb0c3355881
parent 14731 e287dc85f721
child 18024 c0e669065f6d
--- a/Win32OperatingSystem.st	Thu Jan 31 12:38:54 2013 +0000
+++ b/Win32OperatingSystem.st	Thu Jan 31 16:54:54 2013 +0000
@@ -826,7 +826,6 @@
     "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
-
 !Win32OperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -4851,12 +4850,20 @@
 !
 
 getCurrentDirectory
-    |s size|
-
-    s := Unicode16String new:1024.
-    size := self primGetCurrentDirectoryW:1024 string: s.
-    (size isNil or:[size == 0]) ifTrue:[^ ''].
-    ^ (s copyFrom:1 to: size) asSingleByteStringIfPossible
+    "get the current directory"
+
+    |dir|
+%{
+    int ret;
+    wchar_t _aPathName[MAXPATHLEN+1];
+
+    ret = GetCurrentDirectoryW(MAXPATHLEN, _aPathName);
+    if (ret == 0) {
+        __threadErrno = __WIN32_ERR(GetLastError());
+    }
+    dir = __MKU16STRING(_aPathName);
+%}.
+    ^ dir asSingleByteStringIfPossible
 
     "
      self getCurrentDirectory
@@ -5767,32 +5774,6 @@
     "Modified: 10.1.1997 / 19:10:42 / cg"
 !
 
-primGetCurrentDirectory: size string: string
-    <apicall: ulong "GetCurrentDirectoryA" ( ulong pointer ) module: "kernel32.dll" >
-
-    self primitiveFailed.
-
-    "
-     |s size|
-     s := String new:200.
-     size := self primGetCurrentDirectory:200 string: s.
-     s copyFrom:1 to: size
-    "
-!
-
-primGetCurrentDirectoryW: size string: string
-    <apicall: ulong "GetCurrentDirectoryW" ( ulong pointer ) module: "kernel32.dll" >
-
-    self primitiveFailed.
-
-    "
-     |s size|
-     s := Unicode16String new:200.
-     size := self primGetCurrentDirectoryW:200 string: s.
-     s copyFrom:1 to: size
-    "
-!
-
 primGetFileAttributes:aPathName
     "get the file-attributes"
 
@@ -16474,11 +16455,11 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.445 2013-01-17 22:37:55 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.447 2013-01-29 16:37:00 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.445 2013-01-17 22:37:55 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.447 2013-01-29 16:37:00 cg Exp $'
 !
 
 version_SVN
@@ -16486,6 +16467,7 @@
 
 ! !
 
+
 Win32OperatingSystem initialize!
 Win32OperatingSystem::PerformanceData initialize!
 Win32OperatingSystem::RegistryEntry initialize!