UnixOperatingSystem.st
changeset 3759 1601d99a36b5
parent 3737 7560b716b2d5
child 3773 54dd6a5fd72a
--- a/UnixOperatingSystem.st	Thu Aug 13 21:39:15 1998 +0200
+++ b/UnixOperatingSystem.st	Thu Aug 13 21:43:58 1998 +0200
@@ -3771,7 +3771,7 @@
     "Modified: 29.6.1996 / 14:06:54 / cg"
 !
 
-linkFile:oldPath to:newPath
+createHardLinkFrom:oldPath to:newPath
     "link the file 'oldPath' to 'newPath'. The link will be a hard link.
      Return true if successful, false if not."
 
@@ -3779,32 +3779,65 @@
     int ret;
 
     if (__isString(oldPath) && __isString(newPath)) {
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
-	} while (ret < 0 && errno == EINTR);
-	__END_INTERRUPTABLE__
-	if (ret < 0) {
-	    @global(LastErrorNumber) = __MKSMALLINT(errno);
-	    RETURN ( false );
-	}
-	RETURN (true);
+        __BEGIN_INTERRUPTABLE__
+        do {
+            ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
+        } while (ret < 0 && errno == EINTR);
+        __END_INTERRUPTABLE__
+        if (ret < 0) {
+            @global(LastErrorNumber) = __MKSMALLINT(errno);
+            RETURN ( false );
+        }
+        RETURN (true);
     }
 %}.
+    "/
+    "/ bad argument(s) given
+    "/
+    ^ self primitiveFailed 
+
+    "
+     UnixOperatingSystem linkFile:'foo' to:'bar'
+    "
+!
+
+createSymbolicLinkFrom:oldPath to:newPath
+    "make a symbolic link for 'newPath' to the file 'oldPath'.
+     The link will be a soft (symbolic) link.
+     Return true if successful, false if not."
+
+%{
+#ifdef S_IFLNK
+    int ret;
+
+    if (__isString(oldPath) && __isString(newPath)) {
+        __BEGIN_INTERRUPTABLE__
+        do {
+            ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
+        } while (ret < 0 && errno == EINTR);
+        __END_INTERRUPTABLE__
+        if (ret < 0) {
+            @global(LastErrorNumber) = __MKSMALLINT(errno);
+            RETURN ( false );
+        }
+        RETURN (true);
+    }
+#endif
+%}.
     (oldPath isString not or:[newPath isString not]) ifTrue:[
-	"/
-	"/ bad argument(s) given
-	"/
-	^ self primitiveFailed 
+        "/
+        "/ bad argument(s) given
+        "/
+        ^ self primitiveFailed 
     ].
 
     "/
-    "/ this UnixOperatingSystem does not support links
+    "/ this Unix does not seem to support symbolic links
     "/
     ^ UnsupportedOperationSignal raise
 
     "
-     UnixOperatingSystem linkFile:'foo' to:'bar'
+     UnixOperatingSystem symbolicLinkFile:'foo' to:'bar'
     "
 !
 
@@ -4274,15 +4307,6 @@
     "
 !
 
-supportsSymbolicLinks
-    "return true, if the OS supports symbolic links on files/directories.
-     Typically, only Unix returns true here"
-
-    ^ true
-
-    "Modified: / 5.6.1998 / 18:35:11 / cg"
-!
-
 unlockFD:aFileDescriptor
     "clear a file lock on the file represented by aFileDescriptor,
      which was previously aquired by #lockFD:.
@@ -7349,6 +7373,27 @@
      UnixOperatingSystem supportsSelect 
     "
 
+!
+
+supportsSymbolicLinks
+    "return true, if the OS supports symbolic (soft) links;
+     most UNIX'es do; many other OS's do not."
+
+%{  /* NOCONTEXT */
+
+#ifdef S_IFLNK
+    /*
+     * assume yes - if that is defined.
+     */
+    RETURN(true);
+#endif
+%}.
+    ^ false
+
+    "
+     OperatingSystem supportsSymbolicLinks 
+    "
+
 ! !
 
 !UnixOperatingSystem class methodsFor:'private'!
@@ -9107,6 +9152,6 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.35 1998-08-05 17:34:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.36 1998-08-13 19:43:58 cg Exp $'
 ! !
 UnixOperatingSystem initialize!