зеркало из https://github.com/mozilla/pjs.git
Bug 300692 - Win32 nsLocalFile::Create returns not found if no access. r=bsmedberg
This commit is contained in:
Родитель
1f6ae32da2
Коммит
b626e6f50a
|
@ -966,6 +966,7 @@ nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
|
|||
// search for first slash after the drive (or volume) name
|
||||
PRUnichar* slash = wcschr(path, L'\\');
|
||||
|
||||
nsresult directoryCreateError = NS_OK;
|
||||
if (slash)
|
||||
{
|
||||
// skip the first '\\'
|
||||
|
@ -978,12 +979,20 @@ nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
|
|||
|
||||
if (!::CreateDirectoryW(mResolvedPath.get(), NULL)) {
|
||||
rv = ConvertWinError(GetLastError());
|
||||
if (NS_ERROR_FILE_NOT_FOUND == rv &&
|
||||
NS_ERROR_FILE_ACCESS_DENIED == directoryCreateError) {
|
||||
// If a previous CreateDirectory failed due to access, return that.
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
}
|
||||
// perhaps the base path already exists, or perhaps we don't have
|
||||
// permissions to create the directory. NOTE: access denied could
|
||||
// occur on a parent directory even though it exists.
|
||||
if (rv != NS_ERROR_FILE_ALREADY_EXISTS &&
|
||||
rv != NS_ERROR_FILE_ACCESS_DENIED)
|
||||
else if (NS_ERROR_FILE_ALREADY_EXISTS != rv &&
|
||||
NS_ERROR_FILE_ACCESS_DENIED != rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
directoryCreateError = rv;
|
||||
}
|
||||
*slash = L'\\';
|
||||
++slash;
|
||||
|
@ -1006,14 +1015,26 @@ nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
|
|||
PRBool isdir;
|
||||
if (NS_SUCCEEDED(IsDirectory(&isdir)) && isdir)
|
||||
rv = NS_ERROR_FILE_ALREADY_EXISTS;
|
||||
} else if (NS_ERROR_FILE_NOT_FOUND == rv &&
|
||||
NS_ERROR_FILE_ACCESS_DENIED == directoryCreateError) {
|
||||
// If a previous CreateDirectory failed due to access, return that.
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (type == DIRECTORY_TYPE)
|
||||
{
|
||||
if (!::CreateDirectoryW(mResolvedPath.get(), NULL))
|
||||
return ConvertWinError(GetLastError());
|
||||
if (!::CreateDirectoryW(mResolvedPath.get(), NULL)) {
|
||||
rv = ConvertWinError(GetLastError());
|
||||
if (NS_ERROR_FILE_NOT_FOUND == rv &&
|
||||
NS_ERROR_FILE_ACCESS_DENIED == directoryCreateError) {
|
||||
// If a previous CreateDirectory failed due to access, return that.
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
} else {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче