summaryrefslogtreecommitdiffstats
path: root/mac/tclMacFCmd.c
diff options
context:
space:
mode:
authordas <das>2002-10-09 11:54:02 (GMT)
committerdas <das>2002-10-09 11:54:02 (GMT)
commit5451c5041622ded8cdbc5b63e4b5a1ed14a31de6 (patch)
treefcd14750217863bb89fa52d2ccf756a933b9a514 /mac/tclMacFCmd.c
parent22cf6ccfd778871f2ac0415b10e303a0af281e06 (diff)
downloadtcl-5451c5041622ded8cdbc5b63e4b5a1ed14a31de6.zip
tcl-5451c5041622ded8cdbc5b63e4b5a1ed14a31de6.tar.gz
tcl-5451c5041622ded8cdbc5b63e4b5a1ed14a31de6.tar.bz2
* generic/tclInt.decls: made TclSetPreInitScript() declaration
generic as it is used on mac & aqua as well. * generic/tclIntDecls.h: * generic/tclStubInit.c: regen. * generic/tclCompile.h: added prototype for TclCompileVariableCmd. * mac/tclMacPort.h: removed incorrect <fcntl.h> definitions and obsolete <stat.h> definitions. * mac/tclMacChan.c: removed obsolete GetOpenMode() and replaced associated constants with the <fcntl.h> analogues (they existing defs were inconsistent with <fcntl.h> which was causing havoc when Tcl_GetOpenMode was used instead of private GetOpenMode). * mac/tclMacFCmd.c: removed GenerateUniqueName(), use equivalent (and identiaclly named) routine from MoreFiles instead. * mac/tclMacLoad.c: CONSTification, fixes to Vince's last changes. * mac/tclMacFile.c: * mac/tclMacTest.c: * mac/tclMacUnix.c: CONSTification. * mac/tclMacOSA.c: CONSTificcation, sprintf fixes, UH 3.4.x changes; fix for missing autoname token from TclOSACompileCmd. (bdesgraupes) * mac/AppleScript.html(AppleScript delete): doc fix. (bdesgraupes) * mac/tcltkMacBuildSupport.sea.hqx: updated MoreFiles to 1.5.3, updated build instructions for 8.4. * mac/tclMacProjects.sea.hqx: rebuilt archive.
Diffstat (limited to 'mac/tclMacFCmd.c')
-rw-r--r--mac/tclMacFCmd.c80
1 files changed, 10 insertions, 70 deletions
diff --git a/mac/tclMacFCmd.c b/mac/tclMacFCmd.c
index e22b365..f1a39b2 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.17 2002/04/19 14:18:45 das Exp $
+ * RCS: @(#) $Id: tclMacFCmd.c,v 1.18 2002/10/09 11:54:20 das Exp $
*/
#include "tclInt.h"
@@ -65,6 +65,11 @@ CONST TclFileAttrProcs tclpFileAttrProcs[] = {
{GetFileReadOnly, SetFileReadOnly},
{GetFileFinderAttributes, SetFileFinderAttributes}};
+/*
+ * File specific static data
+ */
+
+static long startSeed = 248923489;
/*
* Prototypes for procedure only used in this file
@@ -87,8 +92,6 @@ static int DoRenameFile _ANSI_ARGS_((CONST char *src,
CONST char *dst));
OSErr FSpGetFLockCompat _ANSI_ARGS_((const FSSpec *specPtr,
Boolean *lockedPtr));
-static OSErr GenerateUniqueName _ANSI_ARGS_((short vRefNum,
- long dirID1, long dirID2, Str31 uniqueName));
static OSErr GetFileSpecs _ANSI_ARGS_((CONST char *path,
FSSpec *pathSpecPtr, FSSpec *dirSpecPtr,
Boolean *pathExistsPtr,
@@ -218,7 +221,7 @@ DoRenameFile(
Str31 tmpName;
FSSpec tmpFileSpec;
- err = GenerateUniqueName(dstFileSpec.vRefNum,
+ err = GenerateUniqueName(dstFileSpec.vRefNum, &startSeed,
dstFileSpec.parID, dstFileSpec.parID, tmpName);
if (err == noErr) {
err = FSpRenameCompat(&dstFileSpec, tmpName);
@@ -334,7 +337,7 @@ MoveRename(
* dest directory, and rename temp to target.
*/
- err = GenerateUniqueName(srcFileSpecPtr->vRefNum,
+ err = GenerateUniqueName(srcFileSpecPtr->vRefNum, &startSeed,
srcFileSpecPtr->parID, dstID, tmpName);
FSMakeFSSpecCompat(srcFileSpecPtr->vRefNum, srcFileSpecPtr->parID,
tmpName, &tmpSrcFileSpec);
@@ -436,7 +439,7 @@ DoCopyFile(
* Backup dest file.
*/
- dstErr = GenerateUniqueName(dstFileSpec.vRefNum, dstFileSpec.parID,
+ dstErr = GenerateUniqueName(dstFileSpec.vRefNum, &startSeed, dstFileSpec.parID,
dstFileSpec.parID, tmpName);
if (dstErr == noErr) {
dstErr = FSpRenameCompat(&dstFileSpec, tmpName);
@@ -707,7 +710,7 @@ DoCopyDirectory(
FSpRstFLockCompat(&srcFileSpec);
}
if (err == noErr) {
- err = GenerateUniqueName(dstFileSpec.vRefNum, dstFileSpec.parID,
+ err = GenerateUniqueName(dstFileSpec.vRefNum, &startSeed, dstFileSpec.parID,
dstFileSpec.parID, tmpName);
}
if (err == noErr) {
@@ -934,69 +937,6 @@ DoRemoveDirectory(
/*
*---------------------------------------------------------------------------
*
- * GenerateUniqueName --
- *
- * Generate a filename that is not in either of the two specified
- * directories (on the same volume).
- *
- * Results:
- * Standard macintosh error. On success, uniqueName is filled with
- * the name of the temporary file.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static OSErr
-GenerateUniqueName(
- short vRefNum, /* Volume on which the following directories
- * are located. */
- long dirID1, /* ID of first directory. */
- long dirID2, /* ID of second directory. May be the same
- * as the first. */
- Str31 uniqueName) /* Filled with filename for a file that is
- * not located in either of the above two
- * directories. */
-{
- OSErr err;
- long i;
- CInfoPBRec pb;
- static unsigned char hexStr[16] = "0123456789ABCDEF";
- static long startSeed = 248923489;
-
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioFDirIndex = 0;
- pb.hFileInfo.ioNamePtr = uniqueName;
-
- while (1) {
- startSeed++;
- pb.hFileInfo.ioNamePtr[0] = 8;
- for (i = 1; i <= 8; i++) {
- pb.hFileInfo.ioNamePtr[i] = hexStr[((startSeed >> ((8-i)*4)) & 0xf)];
- }
- pb.hFileInfo.ioDirID = dirID1;
- err = PBGetCatInfoSync(&pb);
- if (err == fnfErr) {
- if (dirID1 != dirID2) {
- pb.hFileInfo.ioDirID = dirID2;
- err = PBGetCatInfoSync(&pb);
- }
- if (err == fnfErr) {
- return noErr;
- }
- }
- if (err == noErr) {
- continue;
- }
- return err;
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
* GetFileSpecs --
*
* Gets FSSpecs for the specified path and its parent directory.