FileStream.st
branchjv
changeset 18011 deb0c3355881
parent 17976 50c2416f962a
parent 14644 e5f19ef20dcd
child 18028 e39da2aa21bc
--- a/FileStream.st	Thu Dec 20 11:48:59 2012 +0000
+++ b/FileStream.st	Sat Jan 19 01:30:00 2013 +0000
@@ -21,6 +21,9 @@
 !FileStream primitiveDefinitions!
 %{
 
+#undef String
+#undef Character
+
 #include <stdio.h>
 #define _STDIO_H_INCLUDED_
 
@@ -49,6 +52,9 @@
 # include <rms.h>
 #endif
 
+#define String  __STX_String
+#define Character __STX_Character
+
 #ifdef WIN32
 # define NO_STDIO
 # ifdef __i386__
@@ -72,6 +78,8 @@
 # undef Message
 # undef Process
 # undef Processor
+# undef String
+# undef Character
 
 # define NOATOM
 # define NOGDICAPMASKS
@@ -89,6 +97,10 @@
 # include <windows.h>
 # include <winsock.h> /* */
 
+# if 1 // defined(__MINGW64__)
+#  include <fcntl.h>
+# endif
+
 # if defined(__BORLANDC__)
 #  include <io.h>
 # else
@@ -137,10 +149,17 @@
 # ifdef __DEF_Processor
 #  define Processor __DEF_Processor
 # endif
+# ifdef __DEF_String
+#  define String __DEF_String
+# endif
+# ifdef __DEF_Character
+#  define Character __DEF_Character
+# endif
 
-# define INT  int
-# define UINT uint
+# define INT  STX_INT
+# define UINT STX_UINT
 
+# if 0
 # ifndef DO_WRAP_CALLS
 #  define STX_C_CALL0(__nm__, __f__)                            __f__((__a1__))
 #  define STX_C_CALL1(__nm__, __f__, __a1__)                    __f__((__a1__))
@@ -152,6 +171,7 @@
 #  define STX_C_CALL2(__nm__, __f__, __a1__, __a2__)            __STX_C_CALL2(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__))
 #  define STX_C_CALL3(__nm__, __f__, __a1__, __a2__, __a3__)    __STX_C_CALL3(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__))
 # endif
+# endif
 
 /* #  define HFILE HANDLE */
 #  define HFILE FILE *
@@ -967,7 +987,7 @@
     "Modified: 30.7.1997 / 16:43:50 / cg"
 ! !
 
-!FileStream methodsFor:'private'!
+!FileStream protectedMethodsFor:'private'!
 
 closeFile
     "low level close - may be redefined in subclasses.
@@ -979,7 +999,9 @@
     ]
 
     "Created: / 13.8.1998 / 12:11:22 / cg"
-!
+! !
+
+!FileStream methodsFor:'private'!
 
 createForReadWrite
     "create/truncate the file for read/write.
@@ -1013,7 +1035,9 @@
      This is a private entry, but maybe useful to open/create a file in a special mode,
      which is proprietrary to the operatingSystem."
 
-    |wasBlocked|
+    |wasBlocked encodedPathName|
+
+    encodedPathName := OperatingSystem encodePath:pathName.
 
 %{
     HFILE f;
@@ -1021,9 +1045,9 @@
     int pass = 0;
 
 retry:
-    if (__isNonNilObject(pathName) && (__isStringLike(openmode) || __isArrayLike(openmode)))
+    if (__isNonNilObject(encodedPathName) && (__isStringLike(openmode) || __isArrayLike(openmode)))
 #ifdef __VMS__
-      if (__qClass(pathName)==String) {
+      if (__isStringLike(pathName)) {
 	do {
 	    /*
 	     * allow passing additional RMS arguments.
@@ -1297,7 +1321,7 @@
       }
 # else /* not WIN32 */
 
-      if (__qClass(pathName)==String) {
+      if (__isStringLike(encodedPathName)) {
 	do {
 	    __BEGIN_INTERRUPTABLE__
 #  ifdef LINUX
@@ -1306,11 +1330,11 @@
 	     * Therefore, check errno and fake a null-ret.
 	     */
 	    __threadErrno = 0;
-	    f = fopen((char *) __stringVal(pathName), (char *) __stringVal(openmode));
+	    f = fopen((char *) __stringVal(encodedPathName), (char *) __stringVal(openmode));
 	    if (__threadErrno == EINTR)
 		f = NULL;
 #  else /* not LINUX */
-	    f = fopen((char *) __stringVal(pathName), (char *) __stringVal(openmode));
+	    f = fopen((char *) __stringVal(encodedPathName), (char *) __stringVal(openmode));
 #  endif /* not LINUX */
 	    __END_INTERRUPTABLE__
 	} while ((f == NULL) && (__threadErrno == EINTR));
@@ -1468,14 +1492,14 @@
 
     handle := self openFile:pathName withMode:openmode attributes:attributeSpec.
     handle isNil ifTrue:[
-        "
-         the open failed for some reason ...
-        "
-        ^ self openError:lastErrorNumber.
+	"
+	 the open failed for some reason ...
+	"
+	^ self openError:lastErrorNumber.
     ].
     position := ZeroPosition.
     buffered isNil ifTrue:[
-        buffered := true.       "default is buffered"
+	buffered := true.       "default is buffered"
     ].
 !
 
@@ -1681,15 +1705,11 @@
 !FileStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.147 2012/10/26 09:56:21 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.152 2013-01-10 11:43:30 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.147 2012/10/26 09:56:21 stefan Exp §'
-!
-
-version_SVN
-    ^ '$Id: FileStream.st 10858 2012-10-29 22:07:56Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.152 2013-01-10 11:43:30 cg Exp $'
 ! !
 
 FileStream initialize!