Bug 1529596 - part 3 - avoid directory creation in the common case; r=aklotz

This change sets up nsLocalFileWin to mirror the behavior of
nsLocalFileUnix, which is all-around more reasonable than the behavior
nsLocalFileWin had before.  We also, in passing, fix up some unnecessary
error-handling code at the end of Create().

Depends on D22360

Differential Revision: https://phabricator.services.mozilla.com/D22361

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-03-07 20:44:00 +00:00
Родитель bf00e79a1e
Коммит 8596aa45d7
1 изменённых файлов: 9 добавлений и 9 удалений

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

@ -1173,6 +1173,14 @@ nsLocalFile::Create(uint32_t aType, uint32_t aAttributes) {
return rv;
}
auto* createFunc = (aType == NORMAL_FILE_TYPE ? do_create : do_mkdir);
rv = createFunc(this, mResolvedPath, aAttributes);
if (NS_SUCCEEDED(rv) || NS_ERROR_FILE_ALREADY_EXISTS == rv) {
return rv;
}
// create directories to target
//
// A given local file can be either one of these forms:
@ -1237,15 +1245,7 @@ nsLocalFile::Create(uint32_t aType, uint32_t aAttributes) {
return directoryCreateError;
}
if (aType == NORMAL_FILE_TYPE) {
return do_create(this, mResolvedPath, aAttributes);
}
if (aType == DIRECTORY_TYPE) {
return do_mkdir(this, mResolvedPath, aAttributes);
}
return NS_ERROR_FILE_UNKNOWN_TYPE;
return createFunc(this, mResolvedPath, aAttributes);
}
NS_IMETHODIMP