Alias resolution now happens almost any time a spec is created from a non-spec. Needed to make things work properly.

This commit is contained in:
mcmullen%netscape.com 1999-06-03 01:28:52 +00:00
Родитель 8bc8b1f9ab
Коммит a0a9c730ae
2 изменённых файлов: 44 добавлений и 14 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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()