diff options
Diffstat (limited to 'mac/tclMacUtil.c')
-rw-r--r-- | mac/tclMacUtil.c | 51 |
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; } |