summaryrefslogtreecommitdiffstats
path: root/mac/tclMacFCmd.c
diff options
context:
space:
mode:
authordas <das>2002-04-19 14:18:33 (GMT)
committerdas <das>2002-04-19 14:18:33 (GMT)
commit26bb2b5da7f034e47d6544e3d84e54c861f61206 (patch)
tree323d0314781d4b46fbb081c3751bb12a9e56feb8 /mac/tclMacFCmd.c
parentd2af1305c613b7c578a4b5be8e1ff487917b4237 (diff)
downloadtcl-26bb2b5da7f034e47d6544e3d84e54c861f61206.zip
tcl-26bb2b5da7f034e47d6544e3d84e54c861f61206.tar.gz
tcl-26bb2b5da7f034e47d6544e3d84e54c861f61206.tar.bz2
2002-04-20 Daniel Steffen <das@users.sourceforge.net>
* generic/tclInt.decls: * generic/tclIntPlatDecls.h: * generic/tclStubInit.c: * mac/tclMacFCmd.c: * mac/tclMacFile.c: * mac/tclMacUtil.c: Modified TclpObjNormalizePath to be alias file aware, and replaced various calls to FSpLocationFrom*Path by calls to new alias file aware versions FSpLLocationFrom*Path. The alias file aware routines don't resolve the last component of a path if it is an alias. This allows [file copy/delete] etc. to act correctly on alias files. (c.f. discussion in Bug #511666)
Diffstat (limited to 'mac/tclMacFCmd.c')
-rw-r--r--mac/tclMacFCmd.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/mac/tclMacFCmd.c b/mac/tclMacFCmd.c
index 1a75ce7..e22b365 100644
--- a/mac/tclMacFCmd.c
+++ b/mac/tclMacFCmd.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: tclMacFCmd.c,v 1.16 2002/01/27 11:09:44 das Exp $
+ * RCS: @(#) $Id: tclMacFCmd.c,v 1.17 2002/04/19 14:18:45 das Exp $
*/
#include "tclInt.h"
@@ -154,7 +154,7 @@ DoRenameFile(
long srcID, dummy;
Boolean srcIsDirectory, dstIsDirectory, dstExists, dstLocked;
- err = FSpLocationFromPath(strlen(src), src, &srcFileSpec);
+ err = FSpLLocationFromPath(strlen(src), src, &srcFileSpec);
if (err == noErr) {
FSpGetDirectoryID(&srcFileSpec, &srcID, &srcIsDirectory);
}
@@ -417,7 +417,7 @@ DoCopyFile(
FSSpec srcFileSpec, dstFileSpec, dstDirSpec, tmpFileSpec;
Str31 tmpName;
- err = FSpLocationFromPath(strlen(src), src, &srcFileSpec);
+ err = FSpLLocationFromPath(strlen(src), src, &srcFileSpec);
if (err == noErr) {
err = GetFileSpecs(dst, &dstFileSpec, &dstDirSpec, &dstExists,
&dstIsDirectory);
@@ -514,7 +514,7 @@ DoDeleteFile(
Boolean isDirectory;
long dirID;
- err = FSpLocationFromPath(strlen(path), path, &fileSpec);
+ err = FSpLLocationFromPath(strlen(path), path, &fileSpec);
if (err == noErr) {
/*
* Since FSpDeleteCompat will delete an empty directory, make sure
@@ -1166,7 +1166,7 @@ GetFileFinderAttributes(
CONST char *native;
native=Tcl_FSGetNativePath(fileName);
- err = FSpLocationFromPath(strlen(native),
+ err = FSpLLocationFromPath(strlen(native),
native, &fileSpec);
if (err == noErr) {
@@ -1244,7 +1244,7 @@ GetFileReadOnly(
CONST char *native;
native=Tcl_FSGetNativePath(fileName);
- err = FSpLocationFromPath(strlen(native),
+ err = FSpLLocationFromPath(strlen(native),
native, &fileSpec);
if (err == noErr) {
@@ -1308,7 +1308,7 @@ SetFileFinderAttributes(
CONST char *native;
native=Tcl_FSGetNativePath(fileName);
- err = FSpLocationFromPath(strlen(native),
+ err = FSpLLocationFromPath(strlen(native),
native, &fileSpec);
if (err == noErr) {
@@ -1400,7 +1400,7 @@ SetFileReadOnly(
CONST char *native;
native=Tcl_FSGetNativePath(fileName);
- err = FSpLocationFromPath(strlen(native),
+ err = FSpLLocationFromPath(strlen(native),
native, &fileSpec);
if (err == noErr) {
@@ -1543,8 +1543,8 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
short vRefNum;
long dirID;
Boolean isDirectory;
- Boolean wasAlias;
- FSSpec fileSpec;
+ Boolean wasAlias=FALSE;
+ FSSpec fileSpec, lastFileSpec;
Tcl_DString nativeds;
@@ -1570,14 +1570,19 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
nextCheckpoint++; cur = path[nextCheckpoint];
}
Tcl_UtfToExternalDString(NULL,path,nextCheckpoint,&nativeds);
- err = FSpLocationFromPath(Tcl_DStringLength(&nativeds),
+ err = FSpLLocationFromPath(Tcl_DStringLength(&nativeds),
Tcl_DStringValue(&nativeds),
&fileSpec);
Tcl_DStringFree(&nativeds);
if (err == noErr) {
+ lastFileSpec=fileSpec;
+ err = ResolveAliasFile(&fileSpec, true, &isDirectory,
+ &wasAlias);
+ if (err == noErr) {
err = FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
currDirValid = ((err == noErr) && isDirectory);
vRefNum = fileSpec.vRefNum;
+ }
}
break;
}
@@ -1651,6 +1656,7 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
break; /* arrived at nonexistent file or dir */
} else {
/* fileSpec could point to an alias, resolve it */
+ lastFileSpec=fileSpec;
err = ResolveAliasFile(&fileSpec, true, &isDirectory,
&wasAlias);
if (err != noErr || !isDirectory) {
@@ -1669,9 +1675,13 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
/* found a new valid subdir in path, continue processing path */
lastCheckpoint=nextCheckpoint+1;
}
+ wasAlias=FALSE;
nextCheckpoint++;
}
+ if (wasAlias)
+ fileSpec=lastFileSpec;
+
/*
* fileSpec now points to a possibly nonexisting file or dir
* inside a valid dir; get full path name to it