Unix.st
changeset 1623 95009f9bfc18
parent 1622 e40404e0a49d
child 1632 355409cd49d8
--- a/Unix.st	Mon Jul 29 21:48:19 1996 +0200
+++ b/Unix.st	Tue Jul 30 15:38:56 1996 +0200
@@ -3446,7 +3446,7 @@
      This is a low-level entry - use Filename protocol."
 
 %{
-#ifdef HAS_FTRUNCATE
+#ifdef HAS_TRUNCATE
     int ret;
 
     if (__isString(aPathName)
@@ -3462,6 +3462,30 @@
 	}
 	RETURN (true);
     }
+#else
+# ifdef HAS_FTRUNCATE
+    int ret;
+    int fd;
+
+    if (__isString(aPathName)
+     && __isSmallInteger(newSize)) {
+	do {
+	    fd = open((char *) __stringVal(aPathName), 2);
+	} while (fd < 0 && errno == EINTR);
+	if (fd < 0) {
+	    @global(LastErrorNumber) = __MKSMALLINT(errno);
+	    RETURN ( false );
+	}
+	
+	ret = ftruncate(fd, __intVal(newSize));
+	close(fd);
+	if (ret < 0) {
+	    @global(LastErrorNumber) = __MKSMALLINT(errno);
+	    RETURN ( false );
+	} 
+	RETURN (true);
+    }
+# endif /* using FTRUNCATE */
 #endif
 %}.
     ^ self primitiveFailed
@@ -7772,6 +7796,6 @@
 !OperatingSystem  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.161 1996-07-29 19:48:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.162 1996-07-30 13:38:56 cg Exp $'
 ! !
 OperatingSystem initialize!