summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-06-21 14:22:27 (GMT)
committervincentdarley <vincentdarley>2002-06-21 14:22:27 (GMT)
commitbb4e2d03bf05b0d16efdf08c97daf5c1f2b35c7b (patch)
tree4ef5a455a5af3008e1352fe5dce00df230fdef43 /unix
parente5f38332d33ee51ce394b1273c7c5cb30e3994d8 (diff)
downloadtcl-bb4e2d03bf05b0d16efdf08c97daf5c1f2b35c7b.zip
tcl-bb4e2d03bf05b0d16efdf08c97daf5c1f2b35c7b.tar.gz
tcl-bb4e2d03bf05b0d16efdf08c97daf5c1f2b35c7b.tar.bz2
tip99
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixFile.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 9edd47e..6724778 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFile.c,v 1.23 2002/06/13 09:40:01 vincentdarley Exp $
+ * RCS: @(#) $Id: tclUnixFile.c,v 1.24 2002/06/21 14:22:29 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -724,10 +724,10 @@ TclpObjStat(pathPtr, bufPtr)
#ifdef S_IFLNK
Tcl_Obj*
-TclpObjLink(pathPtr, toPtr, linkType)
+TclpObjLink(pathPtr, toPtr, linkAction)
Tcl_Obj *pathPtr;
Tcl_Obj *toPtr;
- int linkType;
+ int linkAction;
{
extern Tcl_Filesystem nativeFilesystem;
@@ -738,12 +738,27 @@ TclpObjLink(pathPtr, toPtr, linkType)
if (src == NULL || target == NULL) {
return NULL;
}
- /* We don't recognise these codes */
- if (linkType < 0 || linkType > 2) return NULL;
- if (linkType == 2) {
- if (link(src, target) != 0) return NULL;
+ if (access(src, F_OK) != -1) {
+ /* src exists */
+ errno = EEXIST;
+ return NULL;
+ }
+ if (access(target, F_OK) == -1) {
+ /* target doesn't exist */
+ errno = ENOENT;
+ return NULL;
+ }
+ /*
+ * Check symbolic link flag first, since we prefer to
+ * create these.
+ */
+ if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
+ if (symlink(target, src) != 0) return NULL;
+ } else if (linkAction & TCL_CREATE_HARD_LINK) {
+ if (link(target, src) != 0) return NULL;
} else {
- if (symlink(src, target) != 0) return NULL;
+ errno = ENODEV;
+ return NULL;
}
return toPtr;
} else {