summaryrefslogtreecommitdiffstats
path: root/mac/tclMacUtil.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/tclMacUtil.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/tclMacUtil.c')
-rw-r--r--mac/tclMacUtil.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/mac/tclMacUtil.c b/mac/tclMacUtil.c
index c505c64..a67eeef 100644
--- a/mac/tclMacUtil.c
+++ b/mac/tclMacUtil.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMacUtil.c,v 1.5 2001/11/23 01:28:49 das Exp $
+ * RCS: @(#) $Id: tclMacUtil.c,v 1.6 2002/04/19 14:18:55 das Exp $
*/
#include "tcl.h"
@@ -178,6 +178,10 @@ FSpFindFolder(
err = FSMakeFSSpecCompat(foundVRefNum, foundDirID, "\p", spec);
return err;
}
+
+static int
+FSpLocationFromPathAlias _ANSI_ARGS_((int length, CONST char *path,
+ FSSpecPtr fileSpecPtr, Boolean resolveLink));
/*
*----------------------------------------------------------------------
@@ -204,13 +208,52 @@ FSpLocationFromPath(
CONST char *path, /* The path to convert. */
FSSpecPtr fileSpecPtr) /* On return the spec for the path. */
{
+ return FSpLocationFromPathAlias(length, path, fileSpecPtr, TRUE);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FSpLLocationFromPath --
+ *
+ * This function obtains an FSSpec for a given macintosh path.
+ * Unlike the More Files function FSpLocationFromFullPath, this
+ * function will also accept partial paths and resolve any aliases
+ * along the path expect for the last path component.
+ *
+ * Results:
+ * OSErr code.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+FSpLLocationFromPath(
+ int length, /* Length of path. */
+ CONST char *path, /* The path to convert. */
+ FSSpecPtr fileSpecPtr) /* On return the spec for the path. */
+{
+ return FSpLocationFromPathAlias(length, path, fileSpecPtr, FALSE);
+}
+
+static int
+FSpLocationFromPathAlias(
+ int length, /* Length of path. */
+ CONST char *path, /* The path to convert. */
+ FSSpecPtr fileSpecPtr, /* On return the spec for the path. */
+ Boolean resolveLink) /* Resolve the last path component? */
+{
Str255 fileName;
OSErr err;
short vRefNum;
long dirID;
int pos, cur;
Boolean isDirectory;
- Boolean wasAlias;
+ Boolean wasAlias=FALSE;
+ FSSpec lastFileSpec;
/*
* Check to see if this is a full path. If partial
@@ -277,6 +320,7 @@ FSpLocationFromPath(
}
err = FSMakeFSSpecCompat(vRefNum, dirID, fileName, fileSpecPtr);
if (err != noErr) return err;
+ lastFileSpec=*fileSpecPtr;
err = ResolveAliasFile(fileSpecPtr, true, &isDirectory, &wasAlias);
if (err != noErr) return err;
FSpGetDirectoryID(fileSpecPtr, &dirID, &isDirectory);
@@ -287,6 +331,9 @@ FSpLocationFromPath(
}
}
+ if(!resolveLink && wasAlias)
+ *fileSpecPtr=lastFileSpec;
+
return noErr;
}