This fixes a nsDirectoryIterator bug that bliz, seth and I were working on last night.

Approved by cyeh.
This commit is contained in:
dougt%netscape.com 1999-07-29 14:24:47 +00:00
Родитель 75449d0dff
Коммит d1f9df9cb9
2 изменённых файлов: 17 добавлений и 5 удалений

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

@ -716,8 +716,11 @@ class NS_COM nsDirectoryIterator
PRBool mExists;
PRBool mResoveSymLinks;
#if defined(XP_UNIX) || defined(XP_BEOS)
#if defined(XP_UNIX) || defined(XP_BEOS) || defined (XP_PC)
nsFileSpec mStarting;
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
DIR* mDir;
#elif defined(XP_PC)
PRDir* mDir; // XXX why not use PRDir for Unix too?

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

@ -285,6 +285,8 @@ PRBool nsFileSpec::IsSymlink() const
psl->Release();
}
CoUninitialize();
return isSymlink;
}
@ -298,6 +300,8 @@ nsresult nsFileSpec::ResolveSymlink(PRBool& wasSymlink)
HRESULT hres;
IShellLink* psl;
CoInitialize(NULL);
// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
if (SUCCEEDED(hres))
@ -344,6 +348,8 @@ nsresult nsFileSpec::ResolveSymlink(PRBool& wasSymlink)
psl->Release();
}
CoUninitialize();
if (SUCCEEDED(hres))
return NS_OK;
@ -595,11 +601,13 @@ nsDirectoryIterator::nsDirectoryIterator(const nsFileSpec& inDirectory, PRBool r
//----------------------------------------------------------------------------------------
: mCurrent(inDirectory)
, mDir(nsnull)
, mStarting(inDirectory)
, mExists(PR_FALSE)
, mResoveSymLinks(resolveSymlink)
{
mDir = PR_OpenDir(inDirectory);
mCurrent += "dummy";
mStarting += "dummy";
++(*this);
} // nsDirectoryIterator::nsDirectoryIterator
@ -622,6 +630,7 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
if (entry)
{
mExists = PR_TRUE;
mCurrent = mStarting;
mCurrent.SetLeafName(entry->name);
if (mResoveSymLinks)
{