1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/*
* tclUnixFile.c --
*
* This file contains wrappers around UNIX file handling functions.
* These wrappers mask differences between Windows and UNIX.
*
* Copyright (c) 1995-1998 Sun Microsystems, Inc.
*
* 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.34 2003/11/03 12:48:30 vincentdarley Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
static int NativeMatchType(CONST char* nativeName, Tcl_GlobTypeData *types);
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/*
* tclUnixFile.c --
*
* This file contains wrappers around UNIX file handling functions.
* These wrappers mask differences between Windows and UNIX.
*
* Copyright (c) 1995-1998 Sun Microsystems, Inc.
*
* 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.35 2003/12/12 17:09:34 vincentdarley Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
static int NativeMatchType(CONST char* nativeName, Tcl_GlobTypeData *types);
|
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
|
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 {
errno = ENODEV;
return NULL;
}
return toPtr;
} else {
Tcl_Obj* linkPtr = NULL;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
>
>
|
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
return NULL;
}
/*
* Check symbolic link flag first, since we prefer to
* create these.
*/
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
int targetLen;
Tcl_DString ds;
Tcl_Obj *transPtr;
/*
* Now we don't want to link to the absolute, normalized path.
* Relative links are quite acceptable, as are links to '~user',
* for example.
*/
transPtr = Tcl_FSGetTranslatedPath(NULL, toPtr);
if (transPtr == NULL) {
return NULL;
}
target = Tcl_GetStringFromObj(transPtr, &targetLen);
target = Tcl_UtfToExternalDString(NULL, target, targetLen, &ds);
Tcl_DecrRefCount(transPtr);
if (symlink(target, src) != 0) {
toPtr = NULL;
}
Tcl_DStringFree(&ds);
} else if (linkAction & TCL_CREATE_HARD_LINK) {
if (link(target, src) != 0) {
return NULL;
}
} else {
errno = ENODEV;
return NULL;
}
return toPtr;
} else {
Tcl_Obj* linkPtr = NULL;
|