summaryrefslogtreecommitdiffstats
path: root/mac
diff options
context:
space:
mode:
Diffstat (limited to 'mac')
-rw-r--r--mac/tclMacChan.c17
-rw-r--r--mac/tclMacFCmd.c452
-rw-r--r--mac/tclMacFile.c583
-rw-r--r--mac/tclMacLoad.c13
-rw-r--r--mac/tclMacPort.h10
-rw-r--r--mac/tclMacShLib.exp4
6 files changed, 475 insertions, 604 deletions
diff --git a/mac/tclMacChan.c b/mac/tclMacChan.c
index 2fbac8f..e728c7f 100644
--- a/mac/tclMacChan.c
+++ b/mac/tclMacChan.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: tclMacChan.c,v 1.6 1999/04/16 00:47:19 stanton Exp $
+ * RCS: @(#) $Id: tclMacChan.c,v 1.7 2001/08/30 08:53:15 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -753,7 +753,7 @@ Tcl_Channel
TclpOpenFileChannel(
Tcl_Interp *interp, /* Interpreter for error reporting;
* can be NULL. */
- char *fileName, /* Name of file to open. */
+ Tcl_Obj *pathPtr, /* Name of file to open. */
char *modeString, /* A list of POSIX open modes or
* a string such as "rw". */
int permissions) /* If the open involves creating a
@@ -763,7 +763,6 @@ TclpOpenFileChannel(
Tcl_Channel chan;
int mode;
char *native;
- Tcl_DString ds, buffer;
int errorCode;
mode = GetOpenMode(interp, modeString);
@@ -771,20 +770,18 @@ TclpOpenFileChannel(
return NULL;
}
- if (Tcl_TranslateFileName(interp, fileName, &buffer) == NULL) {
+ native = Tcl_FSGetNativePath(pathPtr);
+ if (native == NULL) {
return NULL;
}
- native = Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&buffer),
- Tcl_DStringLength(&buffer), &ds);
chan = OpenFileChannel(native, mode, permissions, &errorCode);
- Tcl_DStringFree(&ds);
- Tcl_DStringFree(&buffer);
if (chan == NULL) {
Tcl_SetErrno(errorCode);
if (interp != (Tcl_Interp *) NULL) {
- Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ",
- Tcl_PosixError(interp), (char *) NULL);
+ Tcl_AppendResult(interp, "couldn't open \"",
+ Tcl_GetString(pathPtr), "\": ",
+ Tcl_PosixError(interp), (char *) NULL);
}
return NULL;
}
diff --git a/mac/tclMacFCmd.c b/mac/tclMacFCmd.c
index e3c2366..ebc9319 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.9 2001/08/23 17:37:08 vincentdarley Exp $
+ * RCS: @(#) $Id: tclMacFCmd.c,v 1.10 2001/08/30 08:53:15 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -98,77 +98,10 @@ static OSErr MoveRename _ANSI_ARGS_((const FSSpec *srcSpecPtr,
static int Pstrequal _ANSI_ARGS_((ConstStr255Param stringA,
ConstStr255Param stringB));
-int
-TclpObjCreateDirectory(pathPtr)
- Tcl_Obj *pathPtr;
-{
- return DoCreateDirectory(Tcl_FSGetNativePath(pathPtr));
-}
-
-int
-TclpObjDeleteFile(pathPtr)
- Tcl_Obj *pathPtr;
-{
- return DoDeleteFile(Tcl_FSGetNativePath(pathPtr));
-}
-
-int
-TclpObjCopyDirectory(srcPathPtr, destPathPtr, errorPtr)
- Tcl_Obj *srcPathPtr;
- Tcl_Obj *destPathPtr;
- Tcl_Obj **errorPtr;
-{
- Tcl_DString ds;
- int ret;
- ret = DoCopyDirectory(Tcl_FSGetNativePath(srcPathPtr),
- Tcl_FSGetNativePath(destPathPtr), &ds);
- if (ret != TCL_OK) {
- *errorPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
- Tcl_DStringFree(&ds);
- Tcl_IncrRefCount(*errorPtr);
- }
- return ret;
-}
-
-int
-TclpObjCopyFile(srcPathPtr, destPathPtr)
- Tcl_Obj *srcPathPtr;
- Tcl_Obj *destPathPtr;
-{
- return DoCopyFile(Tcl_FSGetNativePath(srcPathPtr),
- Tcl_FSGetNativePath(destPathPtr));
-}
-
-int
-TclpObjRemoveDirectory(pathPtr, recursive, errorPtr)
- Tcl_Obj *pathPtr;
- int recursive;
- Tcl_Obj **errorPtr;
-{
- Tcl_DString ds;
- int ret;
- ret = DoRemoveDirectory(Tcl_FSGetNativePath(pathPtr),recursive, &ds);
- if (ret != TCL_OK) {
- *errorPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
- Tcl_DStringFree(&ds);
- Tcl_IncrRefCount(*errorPtr);
- }
- return ret;
-}
-
-int
-TclpObjRenameFile(srcPathPtr, destPathPtr)
- Tcl_Obj *srcPathPtr;
- Tcl_Obj *destPathPtr;
-{
- return DoRenameFile(Tcl_FSGetNativePath(srcPathPtr),
- Tcl_FSGetNativePath(destPathPtr));
-}
-
/*
*---------------------------------------------------------------------------
*
- * TclpRenameFile, DoRenameFile --
+ * TclpObjRenameFile, DoRenameFile --
*
* Changes the name of an existing file or directory, from src to dst.
* If src and dst refer to the same file or directory, does nothing
@@ -200,23 +133,13 @@ TclpObjRenameFile(srcPathPtr, destPathPtr)
*---------------------------------------------------------------------------
*/
-int
-TclpRenameFile(
- CONST char *src, /* Pathname of file or dir to be renamed
- * (UTF-8). */
- CONST char *dst) /* New pathname of file or directory
- * (UTF-8). */
+int
+TclpObjRenameFile(srcPathPtr, destPathPtr)
+ Tcl_Obj *srcPathPtr;
+ Tcl_Obj *destPathPtr;
{
- int result;
- Tcl_DString srcString, dstString;
-
- Tcl_UtfToExternalDString(NULL, src, -1, &srcString);
- Tcl_UtfToExternalDString(NULL, dst, -1, &dstString);
- result = DoRenameFile(Tcl_DStringValue(&srcString),
- Tcl_DStringValue(&dstString));
- Tcl_DStringFree(&srcString);
- Tcl_DStringFree(&dstString);
- return result;
+ return DoRenameFile(Tcl_FSGetNativePath(srcPathPtr),
+ Tcl_FSGetNativePath(destPathPtr));
}
static int
@@ -451,7 +374,7 @@ MoveRename(
/*
*---------------------------------------------------------------------------
*
- * TclpCopyFile, DoCopyFile --
+ * TclpObjCopyFile, DoCopyFile --
*
* Copy a single file (not a directory). If dst already exists and
* is not a directory, it is removed.
@@ -476,20 +399,12 @@ MoveRename(
*/
int
-TclpCopyFile(
- CONST char *src, /* Pathname of file to be copied (UTF-8). */
- CONST char *dst) /* Pathname of file to copy to (UTF-8). */
+TclpObjCopyFile(srcPathPtr, destPathPtr)
+ Tcl_Obj *srcPathPtr;
+ Tcl_Obj *destPathPtr;
{
- int result;
- Tcl_DString srcString, dstString;
-
- Tcl_UtfToExternalDString(NULL, src, -1, &srcString);
- Tcl_UtfToExternalDString(NULL, dst, -1, &dstString);
- result = DoCopyFile(Tcl_DStringValue(&srcString),
- Tcl_DStringValue(&dstString));
- Tcl_DStringFree(&srcString);
- Tcl_DStringFree(&dstString);
- return result;
+ return DoCopyFile(Tcl_FSGetNativePath(srcPathPtr),
+ Tcl_FSGetNativePath(destPathPtr));
}
static int
@@ -564,7 +479,7 @@ DoCopyFile(
/*
*---------------------------------------------------------------------------
*
- * TclpDeleteFile, DoDeleteFile --
+ * TclpObjDeleteFile, DoDeleteFile --
*
* Removes a single file (not a directory).
*
@@ -583,17 +498,11 @@ DoCopyFile(
*---------------------------------------------------------------------------
*/
-int
-TclpDeleteFile(
- CONST char *path) /* Pathname of file to be removed (UTF-8). */
+int
+TclpObjDeleteFile(pathPtr)
+ Tcl_Obj *pathPtr;
{
- int result;
- Tcl_DString pathString;
-
- Tcl_UtfToExternalDString(NULL, path, -1, &pathString);
- result = DoDeleteFile(Tcl_DStringValue(&pathString));
- Tcl_DStringFree(&pathString);
- return result;
+ return DoDeleteFile(Tcl_FSGetNativePath(pathPtr));
}
static int
@@ -636,7 +545,7 @@ DoDeleteFile(
/*
*---------------------------------------------------------------------------
*
- * TclpCreateDirectory, DoCreateDirectory --
+ * TclpObjCreateDirectory, DoCreateDirectory --
*
* Creates the specified directory. All parent directories of the
* specified directory must already exist. The directory is
@@ -659,17 +568,11 @@ DoDeleteFile(
*---------------------------------------------------------------------------
*/
-int
-TclpCreateDirectory(
- CONST char *path) /* Pathname of directory to create (UTF-8). */
+int
+TclpObjCreateDirectory(pathPtr)
+ Tcl_Obj *pathPtr;
{
- int result;
- Tcl_DString pathString;
-
- Tcl_UtfToExternalDString(NULL, path, -1, &pathString);
- result = DoCreateDirectory(Tcl_DStringValue(&pathString));
- Tcl_DStringFree(&pathString);
- return result;
+ return DoCreateDirectory(Tcl_FSGetNativePath(pathPtr));
}
static int
@@ -697,7 +600,7 @@ DoCreateDirectory(
/*
*---------------------------------------------------------------------------
*
- * TclpCopyDirectory, DoCopyDirectory --
+ * TclpObjCopyDirectory, DoCopyDirectory --
*
* Recursively copies a directory. The target directory dst must
* not already exist. Note that this function does not merge two
@@ -720,25 +623,22 @@ DoCreateDirectory(
*---------------------------------------------------------------------------
*/
-int
-TclpCopyDirectory(
- CONST char *src, /* Pathname of directory to be copied
- * (UTF-8). */
- CONST char *dst, /* Pathname of target directory (UTF-8). */
- Tcl_DString *errorPtr) /* If non-NULL, uninitialized or free
- * DString filled with UTF-8 name of file
- * causing error. */
+int
+TclpObjCopyDirectory(srcPathPtr, destPathPtr, errorPtr)
+ Tcl_Obj *srcPathPtr;
+ Tcl_Obj *destPathPtr;
+ Tcl_Obj **errorPtr;
{
- int result;
- Tcl_DString srcString, dstString;
-
- Tcl_UtfToExternalDString(NULL, src, -1, &srcString);
- Tcl_UtfToExternalDString(NULL, dst, -1, &dstString);
- result = DoCopyDirectory(Tcl_DStringValue(&srcString),
- Tcl_DStringValue(&dstString), errorPtr);
- Tcl_DStringFree(&srcString);
- Tcl_DStringFree(&dstString);
- return result;
+ Tcl_DString ds;
+ int ret;
+ ret = DoCopyDirectory(Tcl_FSGetNativePath(srcPathPtr),
+ Tcl_FSGetNativePath(destPathPtr), &ds);
+ if (ret != TCL_OK) {
+ *errorPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
+ Tcl_DStringFree(&ds);
+ Tcl_IncrRefCount(*errorPtr);
+ }
+ return ret;
}
static int
@@ -900,7 +800,7 @@ CopyErrHandler(
/*
*---------------------------------------------------------------------------
*
- * TclpRemoveDirectory, DoRemoveDirectory --
+ * TclpObjRemoveDirectory, DoRemoveDirectory --
*
* Removes directory (and its contents, if the recursive flag is set).
*
@@ -923,26 +823,21 @@ CopyErrHandler(
*---------------------------------------------------------------------------
*/
-int
-TclpRemoveDirectory(
- CONST char *path, /* Pathname of directory to be removed
- * (UTF-8). */
- int recursive, /* If non-zero, removes directories that
- * are nonempty. Otherwise, will only remove
- * empty directories. */
- Tcl_DString *errorPtr) /* If non-NULL, uninitialized or free
- * DString filled with UTF-8 name of file
- * causing error. */
+int
+TclpObjRemoveDirectory(pathPtr, recursive, errorPtr)
+ Tcl_Obj *pathPtr;
+ int recursive;
+ Tcl_Obj **errorPtr;
{
- int result;
- Tcl_DString pathString;
-
- Tcl_UtfToExternalDString(NULL, path, -1, &pathString);
- result = DoRemoveDirectory(Tcl_DStringValue(&pathString), recursive,
- errorPtr);
- Tcl_DStringFree(&pathString);
-
- return result;
+ Tcl_DString ds;
+ int ret;
+ ret = DoRemoveDirectory(Tcl_FSGetNativePath(pathPtr),recursive, &ds);
+ if (ret != TCL_OK) {
+ *errorPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
+ Tcl_DStringFree(&ds);
+ Tcl_IncrRefCount(*errorPtr);
+ }
+ return ret;
}
static int
@@ -1642,7 +1537,7 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
Tcl_Obj *pathPtr;
int nextCheckpoint;
{
- #define MAXMACFILENAMELEN 31 /* assumed to be < sizeof(StrFileName) */
+ #define MAXMACFILENAMELEN 31 /* assumed to be < sizeof(StrFileName) */
StrFileName fileName;
StringPtr fileNamePtr;
@@ -1653,134 +1548,157 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
long dirID;
Boolean isDirectory;
Boolean wasAlias;
- FSSpec fileSpec;
-
- Tcl_DString nativeds;
+ FSSpec fileSpec;
+
+ Tcl_DString nativeds;
- char cur;
- int firstCheckpoint=nextCheckpoint, lastCheckpoint;
- int origPathLen;
+ char cur;
+ int firstCheckpoint=nextCheckpoint, lastCheckpoint;
+ int origPathLen;
char *path = Tcl_GetStringFromObj(pathPtr,&origPathLen);
-
- {
- int currDirValid=0;
- /*
- * check if substring to first ':' after initial
- * nextCheckpoint is a valid relative or absolute
- * path to a directory, if not we return without
- * normalizing anything
- */
- while (1) {
- cur = path[nextCheckpoint];
- if (cur == ':' || cur == 0) {
- if (cur == ':') { nextCheckpoint++; cur = path[nextCheckpoint]; } /* jump over separator */
- Tcl_UtfToExternalDString(NULL,path,nextCheckpoint,&nativeds);
- err = FSpLocationFromPath(Tcl_DStringLength(&nativeds), Tcl_DStringValue(&nativeds), &fileSpec);
- Tcl_DStringFree(&nativeds);
- if (err == noErr) {
- err = FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
- currDirValid = ((err == noErr) && isDirectory);
- vRefNum = fileSpec.vRefNum;
- }
+ {
+ int currDirValid=0;
+ /*
+ * check if substring to first ':' after initial
+ * nextCheckpoint is a valid relative or absolute
+ * path to a directory, if not we return without
+ * normalizing anything
+ */
+
+ while (1) {
+ cur = path[nextCheckpoint];
+ if (cur == ':' || cur == 0) {
+ if (cur == ':') {
+ /* jump over separator */
+ nextCheckpoint++; cur = path[nextCheckpoint];
+ }
+ Tcl_UtfToExternalDString(NULL,path,nextCheckpoint,&nativeds);
+ err = FSpLocationFromPath(Tcl_DStringLength(&nativeds),
+ Tcl_DStringValue(&nativeds),
+ &fileSpec);
+ Tcl_DStringFree(&nativeds);
+ if (err == noErr) {
+ err = FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
+ currDirValid = ((err == noErr) && isDirectory);
+ vRefNum = fileSpec.vRefNum;
+ }
break;
+ }
+ nextCheckpoint++;
}
- nextCheckpoint++;
- }
-
- if(!currDirValid) return firstCheckpoint; /* can't determine root dir, bail out */
+
+ if(!currDirValid) {
+ /* can't determine root dir, bail out */
+ return firstCheckpoint;
}
+ }
- /*
- * Now vRefNum and dirID point to a valid
- * directory, so walk the rest of the path
- * ( code adapted from FSpLocationFromPath() )
- */
+ /*
+ * Now vRefNum and dirID point to a valid
+ * directory, so walk the rest of the path
+ * ( code adapted from FSpLocationFromPath() )
+ */
- lastCheckpoint=nextCheckpoint;
+ lastCheckpoint=nextCheckpoint;
while (1) {
cur = path[nextCheckpoint];
if (cur == ':' || cur == 0) {
- fileNameLen=nextCheckpoint-lastCheckpoint;
- fileNamePtr=fileName;
- if(fileNameLen==0) {
- if (cur == ':') {
- /*
- * special case for empty dirname i.e. encountered
- * a '::' path component: get parent dir of currDir
- */
- fileName[0]=2;
- strcpy((char *) fileName + 1, "::");
- lastCheckpoint--;
- } else {
- /*
- * empty filename, i.e. want FSSpec for currDir
- */
- fileNamePtr=NULL;
- }
+ fileNameLen=nextCheckpoint-lastCheckpoint;
+ fileNamePtr=fileName;
+ if(fileNameLen==0) {
+ if (cur == ':') {
+ /*
+ * special case for empty dirname i.e. encountered
+ * a '::' path component: get parent dir of currDir
+ */
+ fileName[0]=2;
+ strcpy((char *) fileName + 1, "::");
+ lastCheckpoint--;
} else {
- Tcl_UtfToExternalDString(NULL,&path[lastCheckpoint],fileNameLen,&nativeds);
- fileNameLen=Tcl_DStringLength(&nativeds);
- if(fileNameLen > MAXMACFILENAMELEN) fileNameLen=MAXMACFILENAMELEN;
- fileName[0]=fileNameLen;
- strncpy((char *) fileName + 1, Tcl_DStringValue(&nativeds), fileNameLen);
- Tcl_DStringFree(&nativeds);
+ /*
+ * empty filename, i.e. want FSSpec for currDir
+ */
+ fileNamePtr=NULL;
+ }
+ } else {
+ Tcl_UtfToExternalDString(NULL,&path[lastCheckpoint],
+ fileNameLen,&nativeds);
+ fileNameLen=Tcl_DStringLength(&nativeds);
+ if(fileNameLen > MAXMACFILENAMELEN)
+ fileNameLen=MAXMACFILENAMELEN;
+ fileName[0]=fileNameLen;
+ strncpy((char *) fileName + 1, Tcl_DStringValue(&nativeds),
+ fileNameLen);
+ Tcl_DStringFree(&nativeds);
+ }
+ err=FSMakeFSSpecCompat(vRefNum, dirID, fileNamePtr, &fileSpec);
+ if(err != noErr) {
+ if(err != fnfErr) {
+ /*
+ * this can if trying to get parent of a root
+ * volume via '::' or when using an illegal
+ * filename revert to last checkpoint and stop
+ * processing path further
+ */
+ err=FSMakeFSSpecCompat(vRefNum, dirID, NULL, &fileSpec);
+ if(err != noErr) {
+ /* should never happen, bail out */
+ return firstCheckpoint;
+ }
+ nextCheckpoint=lastCheckpoint;
+ cur = path[lastCheckpoint];
}
- err=FSMakeFSSpecCompat(vRefNum, dirID, fileNamePtr, &fileSpec);
- if(err != noErr) {
- if(err != fnfErr) {
- /*
- * this can if trying to get parent of a root volume via '::'
- * or when using an illegal filename
- * revert to last checkpoint and stop processing path further
- */
- err=FSMakeFSSpecCompat(vRefNum, dirID, NULL, &fileSpec);
- if(err != noErr) return firstCheckpoint; /* should never happen, bail out */
- nextCheckpoint=lastCheckpoint;
- cur = path[lastCheckpoint];
- }
break; /* arrived at nonexistent file or dir */
- } else {
- /* fileSpec could point to an alias, resolve it */
- err = ResolveAliasFile(&fileSpec, true, &isDirectory, &wasAlias);
- if (err != noErr || !isDirectory) break; /* fileSpec doesn't point to a dir */
+ } else {
+ /* fileSpec could point to an alias, resolve it */
+ err = ResolveAliasFile(&fileSpec, true, &isDirectory,
+ &wasAlias);
+ if (err != noErr || !isDirectory) {
+ break; /* fileSpec doesn't point to a dir */
}
- if (cur == 0) break; /* arrived at end of path */
-
- /* fileSpec points to possibly nonexisting subdirectory; validate */
- err = FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
- if (err != noErr || !isDirectory) break; /* fileSpec doesn't point to existing dir */
- vRefNum = fileSpec.vRefNum;
+ }
+ if (cur == 0) break; /* arrived at end of path */
+
+ /* fileSpec points to possibly nonexisting subdirectory; validate */
+ err = FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
+ if (err != noErr || !isDirectory) {
+ break; /* fileSpec doesn't point to existing dir */
+ }
+ vRefNum = fileSpec.vRefNum;
- /* found a new valid subdir in path, continue processing path */
- lastCheckpoint=nextCheckpoint+1;
+ /* found a new valid subdir in path, continue processing path */
+ lastCheckpoint=nextCheckpoint+1;
}
nextCheckpoint++;
}
-
- /*
- * fileSpec now points to a possibly nonexisting file or dir
- * inside a valid dir; get full path name to it
- */
-
- err=FSpPathFromLocation(&fileSpec, &newPathLen, &newPathHandle);
- if(err != noErr) return firstCheckpoint; /* should not see any errors here, bail out */
-
- HLock(newPathHandle);
- Tcl_ExternalToUtfDString(NULL,*newPathHandle,newPathLen,&nativeds);
+
+ /*
+ * fileSpec now points to a possibly nonexisting file or dir
+ * inside a valid dir; get full path name to it
+ */
+
+ err=FSpPathFromLocation(&fileSpec, &newPathLen, &newPathHandle);
+ if(err != noErr) {
+ return firstCheckpoint; /* should not see any errors here, bail out */
+ }
+
+ HLock(newPathHandle);
+ Tcl_ExternalToUtfDString(NULL,*newPathHandle,newPathLen,&nativeds);
if (cur != 0) {
- /* not at end, append remaining path */
+ /* not at end, append remaining path */
if ( newPathLen==0 || *(*newPathHandle+(newPathLen-1))!=':') {
- Tcl_DStringAppend(&nativeds, ":" , 1);
- }
- Tcl_DStringAppend(&nativeds, &path[nextCheckpoint+1], strlen(&path[nextCheckpoint+1]));
+ Tcl_DStringAppend(&nativeds, ":" , 1);
+ }
+ Tcl_DStringAppend(&nativeds, &path[nextCheckpoint+1],
+ strlen(&path[nextCheckpoint+1]));
}
- DisposeHandle(newPathHandle);
-
- fileNameLen=Tcl_DStringLength(&nativeds);
- Tcl_SetStringObj(pathPtr,Tcl_DStringValue(&nativeds),fileNameLen);
- Tcl_DStringFree(&nativeds);
+ DisposeHandle(newPathHandle);
+
+ fileNameLen=Tcl_DStringLength(&nativeds);
+ Tcl_SetStringObj(pathPtr,Tcl_DStringValue(&nativeds),fileNameLen);
+ Tcl_DStringFree(&nativeds);
- return nextCheckpoint+(fileNameLen-origPathLen);
+ return nextCheckpoint+(fileNameLen-origPathLen);
}
diff --git a/mac/tclMacFile.c b/mac/tclMacFile.c
index c8aaf85..cb85d59 100644
--- a/mac/tclMacFile.c
+++ b/mac/tclMacFile.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: tclMacFile.c,v 1.11 2001/08/23 17:37:08 vincentdarley Exp $
+ * RCS: @(#) $Id: tclMacFile.c,v 1.12 2001/08/30 08:53:15 vincentdarley Exp $
*/
/*
@@ -31,9 +31,10 @@
#include <MoreFilesExtras.h>
#include <FSpCompat.h>
-static OSErr FspLocationFromFsPath _ANSI_ARGS_((Tcl_Obj *pathPtr, FSSpec* specPtr));
+static OSErr FspLocationFromFsPath _ANSI_ARGS_((Tcl_Obj *pathPtr,
+ FSSpec* specPtr));
-OSErr
+static OSErr
FspLocationFromFsPath(pathPtr, specPtr)
Tcl_Obj *pathPtr;
FSSpec* specPtr;
@@ -164,15 +165,17 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&dsOrig),
Tcl_DStringLength(&dsOrig), &fileString);
- err = FSpLocationFromPath(Tcl_DStringLength(&fileString), Tcl_DStringValue(&fileString), &dirSpec);
+ err = FSpLocationFromPath(Tcl_DStringLength(&fileString),
+ Tcl_DStringValue(&fileString), &dirSpec);
Tcl_DStringFree(&fileString);
if (err == noErr)
err = FSpGetDirectoryID(&dirSpec, &dirID, &isDirectory);
if ((err != noErr) || !isDirectory) {
/*
- * Check if we had a relative path (unix style rel path compatibility for glob)
+ * Check if we had a relative path (unix style relative path
+ * compatibility for glob)
*/
- Tcl_DStringFree(&dsOrig);
+ Tcl_DStringFree(&dsOrig);
Tcl_DStringAppend(&dsOrig, ":", 1);
Tcl_DStringAppend(&dsOrig, fileName2, -1);
baseLength = Tcl_DStringLength(&dsOrig);
@@ -180,7 +183,8 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&dsOrig),
Tcl_DStringLength(&dsOrig), &fileString);
- err = FSpLocationFromPath(Tcl_DStringLength(&fileString), Tcl_DStringValue(&fileString), &dirSpec);
+ err = FSpLocationFromPath(Tcl_DStringLength(&fileString),
+ Tcl_DStringValue(&fileString), &dirSpec);
Tcl_DStringFree(&fileString);
if (err == noErr)
err = FSpGetDirectoryID(&dirSpec, &dirID, &isDirectory);
@@ -232,8 +236,16 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
int typeOk = 1;
Tcl_DStringSetLength(&dsOrig, baseLength);
Tcl_DStringAppend(&dsOrig, Tcl_DStringValue(&fileString), -1);
+ Tcl_Obj *tempName;
fname = Tcl_DStringValue(&dsOrig);
fnameLen = Tcl_DStringLength(&dsOrig);
+
+ /*
+ * We use this tempName in calls to check the file's
+ * type below. We may also use it for the result.
+ */
+ tempName = Tcl_NewStringObj(fname, fnameLen);
+ Tcl_IncrRefCount(tempName);
if (types == NULL) {
/* If invisible, don't return the file */
@@ -242,7 +254,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
}
} else {
struct stat buf;
-
+
if (pb.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible) {
/* If invisible */
if ((types->perm == 0) ||
@@ -260,11 +272,11 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
((types->perm & TCL_GLOB_PERM_RONLY) &&
!(pb.hFileInfo.ioFlAttrib & 1)) ||
((types->perm & TCL_GLOB_PERM_R) &&
- (TclpAccess(fname, R_OK) != 0)) ||
+ (TclpObjAccess(tempName, R_OK) != 0)) ||
((types->perm & TCL_GLOB_PERM_W) &&
- (TclpAccess(fname, W_OK) != 0)) ||
+ (TclpObjAccess(tempName, W_OK) != 0)) ||
((types->perm & TCL_GLOB_PERM_X) &&
- (TclpAccess(fname, X_OK) != 0))
+ (TclpObjAccess(tempName, X_OK) != 0))
) {
typeOk = 0;
}
@@ -272,7 +284,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
if (typeOk == 1 && types->type != 0) {
if (types->perm == 0) {
/* We haven't yet done a stat on the file */
- if (TclpStat(fname, &buf) != 0) {
+ if (TclpObjStat(tempName, &buf) != 0) {
/* Posix error occurred */
typeOk = 0;
}
@@ -302,7 +314,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
typeOk = 0;
#ifdef S_ISLNK
if (types->type & TCL_GLOB_TYPE_LINK) {
- if (TclpLstat(fname, &buf) == 0) {
+ if (TclpObjLstat(tempName, &buf) == 0) {
if (S_ISLNK(buf.st_mode)) {
typeOk = 1;
}
@@ -325,10 +337,14 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
Tcl_ListObjAppendElement(interp, resultPtr,
Tcl_NewStringObj(fname+1, fnameLen-1));
} else {
- Tcl_ListObjAppendElement(interp, resultPtr,
- Tcl_NewStringObj(fname, fnameLen));
+ Tcl_ListObjAppendElement(interp, resultPtr, tempName);
}
}
+ /*
+ * This will free the object, unless it was inserted in
+ * the result list above.
+ */
+ Tcl_DecrRefCount(tempName);
}
Tcl_DStringFree(&fileString);
itemIndex++;
@@ -341,7 +357,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
/*
*----------------------------------------------------------------------
*
- * TclpAccess --
+ * TclpObjAccess --
*
* This function replaces the library version of access().
*
@@ -354,23 +370,89 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
*----------------------------------------------------------------------
*/
-int
-TclpAccess(
- CONST char *path, /* Path of file to access (UTF-8). */
- int mode) /* Permission setting. */
+int
+TclpObjAccess(pathPtr, mode)
+ Tcl_Obj *pathPtr;
+ int mode;
{
- int ret;
- Tcl_Obj *obj = Tcl_NewStringObj(path,-1);
- Tcl_IncrRefCount(obj);
- ret = TclpObjAccess(obj,mode);
- Tcl_DecrRefCount(obj);
- return ret;
+ HFileInfo fpb;
+ HVolumeParam vpb;
+ OSErr err;
+ FSSpec fileSpec;
+ Boolean isDirectory;
+ long dirID;
+ int full_mode = 0;
+
+ err = FspLocationFromFsPath(pathPtr, &fileSpec);
+
+ if (err != noErr) {
+ errno = TclMacOSErrorToPosixError(err);
+ return -1;
+ }
+
+ /*
+ * Fill the fpb & vpb struct up with info about file or directory.
+ */
+ FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
+ vpb.ioVRefNum = fpb.ioVRefNum = fileSpec.vRefNum;
+ vpb.ioNamePtr = fpb.ioNamePtr = fileSpec.name;
+ if (isDirectory) {
+ fpb.ioDirID = fileSpec.parID;
+ } else {
+ fpb.ioDirID = dirID;
+ }
+
+ fpb.ioFDirIndex = 0;
+ err = PBGetCatInfoSync((CInfoPBPtr)&fpb);
+ if (err == noErr) {
+ vpb.ioVolIndex = 0;
+ err = PBHGetVInfoSync((HParmBlkPtr)&vpb);
+ if (err == noErr) {
+ /*
+ * Use the Volume Info & File Info to determine
+ * access information. If we have got this far
+ * we know the directory is searchable or the file
+ * exists. (We have F_OK)
+ */
+
+ /*
+ * Check to see if the volume is hardware or
+ * software locked. If so we arn't W_OK.
+ */
+ if (mode & W_OK) {
+ if ((vpb.ioVAtrb & 0x0080) || (vpb.ioVAtrb & 0x8000)) {
+ errno = EROFS;
+ return -1;
+ }
+ if (fpb.ioFlAttrib & 0x01) {
+ errno = EACCES;
+ return -1;
+ }
+ }
+
+ /*
+ * Directories are always searchable and executable. But only
+ * files of type 'APPL' are executable.
+ */
+ if (!(fpb.ioFlAttrib & 0x10) && (mode & X_OK)
+ && (fpb.ioFlFndrInfo.fdType != 'APPL')) {
+ return -1;
+ }
+ }
+ }
+
+ if (err != noErr) {
+ errno = TclMacOSErrorToPosixError(err);
+ return -1;
+ }
+
+ return 0;
}
/*
*----------------------------------------------------------------------
*
- * TclpChdir --
+ * TclpObjChdir --
*
* This function replaces the library version of chdir().
*
@@ -379,27 +461,57 @@ TclpAccess(
*
* Side effects:
* See chdir() documentation. Also the cache maintained used by
- * TclGetCwd() is deallocated and set to NULL.
+ * Tcl_FSGetCwd() is deallocated and set to NULL.
*
*----------------------------------------------------------------------
*/
-int
-TclpChdir(
- CONST char *dirName) /* Path to new working directory (UTF-8). */
+int
+TclpObjChdir(pathPtr)
+ Tcl_Obj *pathPtr;
{
- int ret;
- Tcl_Obj *obj = Tcl_NewStringObj(dirName,-1);
- Tcl_IncrRefCount(obj);
- ret = TclpObjChdir(obj);
- Tcl_DecrRefCount(obj);
- return ret;
+ FSSpec spec;
+ OSErr err;
+ Boolean isFolder;
+ long dirID;
+
+ err = FspLocationFromFsPath(pathPtr, &spec);
+
+ if (err != noErr) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ err = FSpGetDirectoryID(&spec, &dirID, &isFolder);
+ if (err != noErr) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (isFolder != true) {
+ errno = ENOTDIR;
+ return -1;
+ }
+
+ err = FSpSetDefaultDir(&spec);
+ if (err != noErr) {
+ switch (err) {
+ case afpAccessDenied:
+ errno = EACCES;
+ break;
+ default:
+ errno = ENOENT;
+ }
+ return -1;
+ }
+
+ return 0;
}
/*
*----------------------------------------------------------------------
*
- * TclpGetCwd --
+ * TclpObjGetCwd --
*
* This function replaces the library version of getcwd().
*
@@ -417,6 +529,21 @@ TclpChdir(
*----------------------------------------------------------------------
*/
+Tcl_Obj*
+TclpObjGetCwd(interp)
+ Tcl_Interp *interp;
+{
+ Tcl_DString ds;
+ if (TclpGetCwd(interp, &ds) != NULL) {
+ Tcl_Obj *cwdPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
+ Tcl_IncrRefCount(cwdPtr);
+ Tcl_DStringFree(&ds);
+ return cwdPtr;
+ } else {
+ return NULL;
+ }
+}
+
char *
TclpGetCwd(
Tcl_Interp *interp, /* If non-NULL, used for error reporting. */
@@ -585,35 +712,32 @@ TclpReadlink(
/*
*----------------------------------------------------------------------
*
- * TclpLstat --
+ * TclpObjLstat --
*
* This function replaces the library version of lstat().
*
* Results:
- * See stat() documentation.
+ * See lstat() documentation.
*
* Side effects:
- * See stat() documentation.
+ * See lstat() documentation.
*
*----------------------------------------------------------------------
*/
-int
-TclpLstat(
- CONST char *path, /* Path of file to stat (in UTF-8). */
- struct stat *bufPtr) /* Filled with results of stat call. */
+int
+TclpObjLstat(pathPtr, buf)
+ Tcl_Obj *pathPtr;
+ struct stat *buf;
{
- /*
- * FIXME: Emulate TclpLstat
- */
-
- return TclpStat(path, bufPtr);
+ /* This needs to be enhanced to deal with aliases */
+ return TclpObjStat(pathPtr, buf);
}
/*
*----------------------------------------------------------------------
*
- * TclpStat --
+ * TclpObjStat --
*
* This function replaces the library version of stat().
*
@@ -626,17 +750,107 @@ TclpLstat(
*----------------------------------------------------------------------
*/
-int
-TclpStat(
- CONST char *path, /* Path of file to stat (in UTF-8). */
- struct stat *bufPtr) /* Filled with results of stat call. */
+int
+TclpObjStat(pathPtr, bufPtr)
+ Tcl_Obj *pathPtr;
+ struct stat *bufPtr;
{
- int ret;
- Tcl_Obj *obj = Tcl_NewStringObj(path,-1);
- Tcl_IncrRefCount(obj);
- ret = TclpObjStat(obj,bufPtr);
- Tcl_DecrRefCount(obj);
- return ret;
+ HFileInfo fpb;
+ HVolumeParam vpb;
+ OSErr err;
+ FSSpec fileSpec;
+ Boolean isDirectory;
+ long dirID;
+
+ err = FspLocationFromFsPath(pathPtr, &fileSpec);
+
+ if (err != noErr) {
+ errno = TclMacOSErrorToPosixError(err);
+ return -1;
+ }
+
+ /*
+ * Fill the fpb & vpb struct up with info about file or directory.
+ */
+
+ FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
+ vpb.ioVRefNum = fpb.ioVRefNum = fileSpec.vRefNum;
+ vpb.ioNamePtr = fpb.ioNamePtr = fileSpec.name;
+ if (isDirectory) {
+ fpb.ioDirID = fileSpec.parID;
+ } else {
+ fpb.ioDirID = dirID;
+ }
+
+ fpb.ioFDirIndex = 0;
+ err = PBGetCatInfoSync((CInfoPBPtr)&fpb);
+ if (err == noErr) {
+ vpb.ioVolIndex = 0;
+ err = PBHGetVInfoSync((HParmBlkPtr)&vpb);
+ if (err == noErr && bufPtr != NULL) {
+ /*
+ * Files are always readable by everyone.
+ */
+
+ bufPtr->st_mode = S_IRUSR | S_IRGRP | S_IROTH;
+
+ /*
+ * Use the Volume Info & File Info to fill out stat buf.
+ */
+ if (fpb.ioFlAttrib & 0x10) {
+ bufPtr->st_mode |= S_IFDIR;
+ bufPtr->st_nlink = 2;
+ } else {
+ bufPtr->st_nlink = 1;
+ if (fpb.ioFlFndrInfo.fdFlags & 0x8000) {
+ bufPtr->st_mode |= S_IFLNK;
+ } else {
+ bufPtr->st_mode |= S_IFREG;
+ }
+ }
+ if ((fpb.ioFlAttrib & 0x10) || (fpb.ioFlFndrInfo.fdType == 'APPL')) {
+ /*
+ * Directories and applications are executable by everyone.
+ */
+
+ bufPtr->st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
+ }
+ if ((fpb.ioFlAttrib & 0x01) == 0){
+ /*
+ * If not locked, then everyone has write acces.
+ */
+
+ bufPtr->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ }
+ bufPtr->st_ino = fpb.ioDirID;
+ bufPtr->st_dev = fpb.ioVRefNum;
+ bufPtr->st_uid = -1;
+ bufPtr->st_gid = -1;
+ bufPtr->st_rdev = 0;
+ bufPtr->st_size = fpb.ioFlLgLen;
+ bufPtr->st_blksize = vpb.ioVAlBlkSiz;
+ bufPtr->st_blocks = (bufPtr->st_size + bufPtr->st_blksize - 1)
+ / bufPtr->st_blksize;
+
+ /*
+ * The times returned by the Mac file system are in the
+ * local time zone. We convert them to GMT so that the
+ * epoch starts from GMT. This is also consistent with
+ * what is returned from "clock seconds".
+ */
+
+ bufPtr->st_atime = bufPtr->st_mtime = fpb.ioFlMdDat
+ - TclpGetGMTOffset() + tcl_mac_epoch_offset;
+ bufPtr->st_ctime = fpb.ioFlCrDat - TclpGetGMTOffset()
+ + tcl_mac_epoch_offset;
+ }
+ }
+
+ if (err != noErr) {
+ errno = TclMacOSErrorToPosixError(err);
+ }
+
+ return (err == noErr ? 0 : -1);
}
/*
@@ -822,251 +1036,6 @@ TclMacChmod(
return 0;
}
-int
-TclpObjStat(pathPtr, bufPtr)
- Tcl_Obj *pathPtr;
- struct stat *bufPtr;
-{
- HFileInfo fpb;
- HVolumeParam vpb;
- OSErr err;
- FSSpec fileSpec;
- Boolean isDirectory;
- long dirID;
-
- err = FspLocationFromFsPath(pathPtr, &fileSpec);
-
- if (err != noErr) {
- errno = TclMacOSErrorToPosixError(err);
- return -1;
- }
-
- /*
- * Fill the fpb & vpb struct up with info about file or directory.
- */
-
- FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
- vpb.ioVRefNum = fpb.ioVRefNum = fileSpec.vRefNum;
- vpb.ioNamePtr = fpb.ioNamePtr = fileSpec.name;
- if (isDirectory) {
- fpb.ioDirID = fileSpec.parID;
- } else {
- fpb.ioDirID = dirID;
- }
-
- fpb.ioFDirIndex = 0;
- err = PBGetCatInfoSync((CInfoPBPtr)&fpb);
- if (err == noErr) {
- vpb.ioVolIndex = 0;
- err = PBHGetVInfoSync((HParmBlkPtr)&vpb);
- if (err == noErr && bufPtr != NULL) {
- /*
- * Files are always readable by everyone.
- */
-
- bufPtr->st_mode = S_IRUSR | S_IRGRP | S_IROTH;
-
- /*
- * Use the Volume Info & File Info to fill out stat buf.
- */
- if (fpb.ioFlAttrib & 0x10) {
- bufPtr->st_mode |= S_IFDIR;
- bufPtr->st_nlink = 2;
- } else {
- bufPtr->st_nlink = 1;
- if (fpb.ioFlFndrInfo.fdFlags & 0x8000) {
- bufPtr->st_mode |= S_IFLNK;
- } else {
- bufPtr->st_mode |= S_IFREG;
- }
- }
- if ((fpb.ioFlAttrib & 0x10) || (fpb.ioFlFndrInfo.fdType == 'APPL')) {
- /*
- * Directories and applications are executable by everyone.
- */
-
- bufPtr->st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
- }
- if ((fpb.ioFlAttrib & 0x01) == 0){
- /*
- * If not locked, then everyone has write acces.
- */
-
- bufPtr->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- }
- bufPtr->st_ino = fpb.ioDirID;
- bufPtr->st_dev = fpb.ioVRefNum;
- bufPtr->st_uid = -1;
- bufPtr->st_gid = -1;
- bufPtr->st_rdev = 0;
- bufPtr->st_size = fpb.ioFlLgLen;
- bufPtr->st_blksize = vpb.ioVAlBlkSiz;
- bufPtr->st_blocks = (bufPtr->st_size + bufPtr->st_blksize - 1)
- / bufPtr->st_blksize;
-
- /*
- * The times returned by the Mac file system are in the
- * local time zone. We convert them to GMT so that the
- * epoch starts from GMT. This is also consistant with
- * what is returned from "clock seconds".
- */
-
- bufPtr->st_atime = bufPtr->st_mtime = fpb.ioFlMdDat - TclpGetGMTOffset() + tcl_mac_epoch_offset;
- bufPtr->st_ctime = fpb.ioFlCrDat - TclpGetGMTOffset() + tcl_mac_epoch_offset;
- }
- }
-
- if (err != noErr) {
- errno = TclMacOSErrorToPosixError(err);
- }
-
- return (err == noErr ? 0 : -1);
-}
-
-Tcl_Obj*
-TclpObjGetCwd(interp)
- Tcl_Interp *interp;
-{
- Tcl_DString ds;
- if (TclpGetCwd(interp, &ds) != NULL) {
- Tcl_Obj *cwdPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), -1);
- Tcl_IncrRefCount(cwdPtr);
- Tcl_DStringFree(&ds);
- return cwdPtr;
- } else {
- return NULL;
- }
-}
-
-int
-TclpObjChdir(pathPtr)
- Tcl_Obj *pathPtr;
-{
- FSSpec spec;
- OSErr err;
- Boolean isFolder;
- long dirID;
-
- err = FspLocationFromFsPath(pathPtr, &spec);
-
- if (err != noErr) {
- errno = ENOENT;
- return -1;
- }
-
- err = FSpGetDirectoryID(&spec, &dirID, &isFolder);
- if (err != noErr) {
- errno = ENOENT;
- return -1;
- }
-
- if (isFolder != true) {
- errno = ENOTDIR;
- return -1;
- }
-
- err = FSpSetDefaultDir(&spec);
- if (err != noErr) {
- switch (err) {
- case afpAccessDenied:
- errno = EACCES;
- break;
- default:
- errno = ENOENT;
- }
- return -1;
- }
-
- return 0;
-}
-
-int
-TclpObjAccess(pathPtr, mode)
- Tcl_Obj *pathPtr;
- int mode;
-{
- HFileInfo fpb;
- HVolumeParam vpb;
- OSErr err;
- FSSpec fileSpec;
- Boolean isDirectory;
- long dirID;
- int full_mode = 0;
-
- err = FspLocationFromFsPath(pathPtr, &fileSpec);
-
- if (err != noErr) {
- errno = TclMacOSErrorToPosixError(err);
- return -1;
- }
-
- /*
- * Fill the fpb & vpb struct up with info about file or directory.
- */
- FSpGetDirectoryID(&fileSpec, &dirID, &isDirectory);
- vpb.ioVRefNum = fpb.ioVRefNum = fileSpec.vRefNum;
- vpb.ioNamePtr = fpb.ioNamePtr = fileSpec.name;
- if (isDirectory) {
- fpb.ioDirID = fileSpec.parID;
- } else {
- fpb.ioDirID = dirID;
- }
-
- fpb.ioFDirIndex = 0;
- err = PBGetCatInfoSync((CInfoPBPtr)&fpb);
- if (err == noErr) {
- vpb.ioVolIndex = 0;
- err = PBHGetVInfoSync((HParmBlkPtr)&vpb);
- if (err == noErr) {
- /*
- * Use the Volume Info & File Info to determine
- * access information. If we have got this far
- * we know the directory is searchable or the file
- * exists. (We have F_OK)
- */
-
- /*
- * Check to see if the volume is hardware or
- * software locked. If so we arn't W_OK.
- */
- if (mode & W_OK) {
- if ((vpb.ioVAtrb & 0x0080) || (vpb.ioVAtrb & 0x8000)) {
- errno = EROFS;
- return -1;
- }
- if (fpb.ioFlAttrib & 0x01) {
- errno = EACCES;
- return -1;
- }
- }
-
- /*
- * Directories are always searchable and executable. But only
- * files of type 'APPL' are executable.
- */
- if (!(fpb.ioFlAttrib & 0x10) && (mode & X_OK)
- && (fpb.ioFlFndrInfo.fdType != 'APPL')) {
- return -1;
- }
- }
- }
-
- if (err != noErr) {
- errno = TclMacOSErrorToPosixError(err);
- return -1;
- }
-
- return 0;
-}
-
-int
-TclpObjLstat(pathPtr, buf)
- Tcl_Obj *pathPtr;
- struct stat *buf;
-{
- return TclpObjStat(pathPtr, buf);
-}
-
/*
*----------------------------------------------------------------------
@@ -1089,7 +1058,7 @@ TclpTempFileName()
{
char fileName[L_tmpnam];
- if (tmpnam(fileName) == NULL) { /* INTL: Native. */
+ if (tmpnam(fileName) == NULL) { /* INTL: Native. */
return NULL;
}
diff --git a/mac/tclMacLoad.c b/mac/tclMacLoad.c
index daf87ca..fd355ae 100644
--- a/mac/tclMacLoad.c
+++ b/mac/tclMacLoad.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: tclMacLoad.c,v 1.4 1999/10/15 04:47:12 jingham Exp $
+ * RCS: @(#) $Id: tclMacLoad.c,v 1.5 2001/08/30 08:53:15 vincentdarley Exp $
*/
#include <CodeFragments.h>
@@ -99,7 +99,7 @@ typedef struct CfrgItem CfrgItem;
int
TclpLoadFile(
Tcl_Interp *interp, /* Used for error reporting. */
- char *fileName, /* Name of the file containing the desired
+ Tcl_Obj *pathPtr, /* Name of the file containing the desired
* code. */
char *sym1, char *sym2, /* Names of two procedures to look up in
* the file's symbol table. */
@@ -122,7 +122,6 @@ TclpLoadFile(
UInt32 length = kCFragGoesToEOF;
char packageName[255];
Str255 errName;
- Tcl_DString ds;
char *native;
/*
@@ -134,9 +133,8 @@ TclpLoadFile(
Tcl_UtfToLower(packageName);
*(Tcl_UtfAtIndex(packageName, Tcl_NumUtfChars(packageName, -1) - 5)) = 0;
- native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
+ native = Tcl_FSGetNativePath(pathPtr);
err = FSpLocationFromPath(strlen(native), native, &fileSpec);
- Tcl_DStringFree(&ds);
if (err != noErr) {
Tcl_SetResult(interp, "could not locate shared library", TCL_STATIC);
@@ -199,8 +197,9 @@ TclpLoadFile(
kLoadCFrag, &connID, &dummy, errName);
if (err != fragNoErr) {
p2cstr(errName);
- Tcl_AppendResult(interp, "couldn't load file \"", fileName,
- "\": ", errName, (char *) NULL);
+ Tcl_AppendResult(interp, "couldn't load file \"",
+ Tcl_GetString(pathPtr),
+ "\": ", errName, (char *) NULL);
return TCL_ERROR;
}
diff --git a/mac/tclMacPort.h b/mac/tclMacPort.h
index 1336f87..142a570 100644
--- a/mac/tclMacPort.h
+++ b/mac/tclMacPort.h
@@ -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: tclMacPort.h,v 1.12 2001/07/31 19:12:07 vincentdarley Exp $
+ * RCS: @(#) $Id: tclMacPort.h,v 1.13 2001/08/30 08:53:15 vincentdarley Exp $
*/
@@ -248,14 +248,6 @@ extern char **environ;
#define TclSetSystemEnv(a,b)
#define tzset()
-/*
- * The following defines replace the Macintosh version of the POSIX
- * functions "stat" and "access". The various compilier vendors
- * don't implement this function well nor consistantly.
- */
-/* int TclpStat(const char *path, struct stat *bufPtr); */
-int TclpLstat(const char *path, struct stat *bufPtr);
-
char *TclpFindExecutable(const char *argv0);
int TclpFindVariable(CONST char *name, int *lengthPtr);
diff --git a/mac/tclMacShLib.exp b/mac/tclMacShLib.exp
index 020380f..8ada490 100644
--- a/mac/tclMacShLib.exp
+++ b/mac/tclMacShLib.exp
@@ -197,7 +197,6 @@ SetIsStationery
SetNameLocked
Share
StrToAddr
-TclAccess
TclAllocateFreeObjects
TclChdir
TclCleanupByteCode
@@ -303,7 +302,6 @@ TclIsProc
TclLoadFile
TclLooksLikeInt
TclLookupVar
-TclpAccess
TclMacCreateEnv
TclMacExitHandler
TclMacFOpenHack
@@ -313,7 +311,6 @@ TclMacOSErrorToPosixError
TclMacReadlink
TclMacRemoveTimer
TclMacStartTimer
-TclpStat
TclMacTimerExpired
TclMatchFiles
TclNeedSpace
@@ -338,7 +335,6 @@ TclSetEnv
TclSetIndexedScalar
TclSetupEnv
TclSockGetPort
-TclStat
TclTeardownNamespace
TclTestChannelCmd
TclTestChannelEventCmd