From dee7faf9fbd80b5d4c9871f88c48751568f14f5a Mon Sep 17 00:00:00 2001 From: "mcmullen%netscape.com" Date: Thu, 3 Jun 1999 01:28:52 +0000 Subject: [PATCH] Alias resolution now happens almost any time a spec is created from a non-spec. Needed to make things work properly. git-svn-id: svn://10.0.0.236/trunk@33465 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsFileSpec.h | 8 ++--- mozilla/xpcom/io/nsFileSpecMac.cpp | 50 ++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/mozilla/xpcom/io/nsFileSpec.h b/mozilla/xpcom/io/nsFileSpec.h index e235f46cff0..558aab2d178 100644 --- a/mozilla/xpcom/io/nsFileSpec.h +++ b/mozilla/xpcom/io/nsFileSpec.h @@ -340,10 +340,8 @@ class NS_COM nsFileSpec short vRefNum, long parID, ConstStr255Param name); - nsFileSpec(const FSSpec& inSpec) - : mSpec(inSpec), mError(NS_OK) {} - void operator = (const FSSpec& inSpec) - { mSpec = inSpec; mError = NS_OK; } + nsFileSpec(const FSSpec& inSpec); + void operator = (const FSSpec& inSpec); operator FSSpec* () { return &mSpec; } operator const FSSpec* const () { return &mSpec; } @@ -715,6 +713,8 @@ class NS_COM nsDirectoryIterator #elif defined(XP_PC) PRDir* mDir; // XXX why not use PRDir for Unix too? #elif defined(XP_MAC) + short mVRefNum; + long mParID; short mIndex; short mMaxIndex; #endif diff --git a/mozilla/xpcom/io/nsFileSpecMac.cpp b/mozilla/xpcom/io/nsFileSpecMac.cpp index 25526da1c3f..27b501f2017 100644 --- a/mozilla/xpcom/io/nsFileSpecMac.cpp +++ b/mozilla/xpcom/io/nsFileSpecMac.cpp @@ -597,6 +597,26 @@ nsFileSpec::nsFileSpec() mSpec.name[0] = '\0'; } +//---------------------------------------------------------------------------------------- +nsFileSpec::nsFileSpec(const FSSpec& inSpec) +//---------------------------------------------------------------------------------------- +: mSpec(inSpec) +, mError(NS_OK) +{ + PRBool dummy; + ResolveAlias(dummy); +} + +//---------------------------------------------------------------------------------------- +void nsFileSpec::operator = (const FSSpec& inSpec) +//---------------------------------------------------------------------------------------- +{ + mSpec = inSpec; + mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); +} + //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -618,6 +638,8 @@ nsFileSpec::nsFileSpec(const char* inNativePathString, PRBool inCreateDirs) mSpec, inCreateDirs)); if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); } // nsFileSpec::nsFileSpec //---------------------------------------------------------------------------------------- @@ -633,6 +655,8 @@ nsFileSpec::nsFileSpec(const nsString& inNativePathString, PRBool inCreateDirs) mSpec, inCreateDirs)); if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); } // nsFileSpec::nsFileSpec //---------------------------------------------------------------------------------------- @@ -642,6 +666,8 @@ nsFileSpec::nsFileSpec(short vRefNum, long parID, ConstStr255Param name) mError = NS_FILE_RESULT(::FSMakeFSSpec(vRefNum, parID, name, &mSpec)); if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); } //---------------------------------------------------------------------------------------- @@ -664,6 +690,8 @@ void nsFileSpec::operator = (const char* inString) MacFileHelpers::FSSpecFromPathname(inString, mSpec, true)); if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); } // nsFileSpec::operator = //---------------------------------------------------------------------------------------- @@ -835,6 +863,8 @@ void nsFileSpec::operator += (const char* inRelativePath) } if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; + PRBool dummy; + ResolveAlias(dummy); } // nsFileSpec::operator += //---------------------------------------------------------------------------------------- @@ -1012,7 +1042,7 @@ static void AssignFromPath(nsFilePath& ioPath, const char* inString, PRBool inCr inString, spec, false, - false, + true, // resolve alias true, inCreateDirs); // Now we have a spec, @@ -1093,7 +1123,7 @@ nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs) inString + kFileURLPrefixLength, mFileSpec.mSpec, true, // need to decode - false, // don't resolve alias + true, // resolve alias false, // must be a full path inCreateDirs)); if (mFileSpec.mError == NS_FILE_RESULT(fnfErr)) @@ -1113,7 +1143,7 @@ nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs) cstring + kFileURLPrefixLength, mFileSpec.mSpec, true, // need to decode - false, // don't resolve alias + true, // resolve alias false, // must be a full path inCreateDirs)); if (mFileSpec.mError == NS_FILE_RESULT(fnfErr)) @@ -1166,7 +1196,7 @@ void nsFileURL::operator = (const char* inString) inString + kFileURLPrefixLength, mFileSpec.mSpec, true, // need to decode - false, // don't resolve alias + true, // resolve alias false, // must be a full path false)); // don't create dirs. if (mFileSpec.mError == NS_FILE_RESULT(fnfErr)) @@ -1195,8 +1225,8 @@ nsDirectoryIterator::nsDirectoryIterator( return; // Sorry about this, there seems to be a bug in CWPro 4: FSSpec& currentSpec = mCurrent.nsFileSpec::operator FSSpec&(); - currentSpec.vRefNum = currentSpec.vRefNum; - currentSpec.parID = dipb->ioDrDirID; + mVRefNum = currentSpec.vRefNum; + mParID = dipb->ioDrDirID; mMaxIndex = pb.dirInfo.ioDrNmFls; if (inIterateDirection > 0) { @@ -1221,14 +1251,14 @@ OSErr nsDirectoryIterator::SetToIndex() dipb->ioFDirIndex = mIndex; // Sorry about this, there seems to be a bug in CWPro 4: FSSpec& currentSpec = mCurrent.nsFileSpec::operator FSSpec&(); - dipb->ioVRefNum = currentSpec.vRefNum; /* Might need to use vRefNum, not sure*/ - dipb->ioDrDirID = currentSpec.parID; + dipb->ioVRefNum = mVRefNum; /* Might need to use vRefNum, not sure*/ + dipb->ioDrDirID = mParID; dipb->ioNamePtr = objectName; OSErr err = PBGetCatInfoSync(&cipb); FSSpec temp; if (err == noErr) - err = FSMakeFSSpec(currentSpec.vRefNum, currentSpec.parID, objectName, &temp); - currentSpec = temp; // use the operator: it clears the string cache etc. + err = FSMakeFSSpec(mVRefNum, mParID, objectName, &temp); + mCurrent = temp; // use the operator: it clears the string cache and resolves the alias. mExists = err == noErr; return err; } // nsDirectoryIterator::SetToIndex()