mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1462937: Update callers to use nsIFile::GetDirectoryEntries as a nsIDirectoryEnumerator. r=froydnj
MozReview-Commit-ID: Iv4T1MVAF5 --HG-- extra : rebase_source : 1c518883d082884db7f9323a5acc20361228c26b extra : histedit_source : 70a73c23d1199d3bfbb5379c78930401166c094b
This commit is contained in:
parent
bdc3174614
commit
6b12d08f7d
@ -248,7 +248,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD
|
||||
let dest = createSubDir("datareporting");
|
||||
let enumerator = dataReportingDir.directoryEntries;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = enumerator.nextFile;
|
||||
if (file.isDirectory() || !toCopy.includes(file.leafName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -291,8 +291,7 @@ function getEdgeLocalDataFolder() {
|
||||
// Let's try the long way:
|
||||
let dirEntries = packages.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
let subDir = dirEntries.getNext();
|
||||
subDir.QueryInterface(Ci.nsIFile);
|
||||
let subDir = dirEntries.nextFile;
|
||||
if (subDir.leafName.startsWith("Microsoft.MicrosoftEdge") && subDir.isReadable() &&
|
||||
subDir.isDirectory()) {
|
||||
gEdgeDir = subDir;
|
||||
@ -388,7 +387,7 @@ Bookmarks.prototype = {
|
||||
let entries = aSourceFolder.directoryEntries;
|
||||
let rv = [];
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
try {
|
||||
// Make sure that entry.path == entry.target to not follow .lnk folder
|
||||
// shortcuts which could lead to infinite cycles.
|
||||
@ -509,7 +508,7 @@ Cookies.prototype = {
|
||||
for (let folder of folders) {
|
||||
let entries = folder.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
// Skip eventual bogus entries.
|
||||
if (!entry.isFile() || !/\.(cookie|txt)$/.test(entry.leafName))
|
||||
continue;
|
||||
|
@ -2848,7 +2848,7 @@ dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
|
||||
let entries = [];
|
||||
let enumerator = directory.directoryEntries;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = enumerator.nextFile;
|
||||
entries.push({ name: file.leafName, is_dir: file.isDirectory() });
|
||||
}
|
||||
return [PP_OK, { contents: { count: entries.length, entries } }];
|
||||
|
@ -42,7 +42,7 @@ function clearPendingCrashReports() {
|
||||
let entries = dir.directoryEntries;
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
if (entry.isFile()) {
|
||||
entry.remove(false);
|
||||
}
|
||||
|
@ -1874,26 +1874,15 @@ Client::GetUsageForOrigin(PersistenceType aPersistenceType,
|
||||
DebugOnly<bool> exists;
|
||||
MOZ_ASSERT(NS_SUCCEEDED(directory->Exists(&exists)) && exists);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
|
||||
hasMore && !aCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (NS_WARN_IF(!file)) {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||
file && !aCanceled) {
|
||||
int64_t fileSize;
|
||||
rv = file->GetFileSize(&fileSize);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
39
dom/cache/FileUtils.cpp
vendored
39
dom/cache/FileUtils.cpp
vendored
@ -450,19 +450,13 @@ BodyDeleteOrphanedFiles(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
rv = dir->Append(NS_LITERAL_STRING("morgue"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
// Iterate over all the intermediate morgue subdirs
|
||||
bool hasMore = false;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsIFile> subdir = do_QueryInterface(entry);
|
||||
|
||||
nsCOMPtr<nsIFile> subdir;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(subdir))) && subdir) {
|
||||
bool isDir = false;
|
||||
rv = subdir->IsDirectory(&isDir);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
@ -474,20 +468,14 @@ BodyDeleteOrphanedFiles(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir,
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> subEntries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> subEntries;
|
||||
rv = subdir->GetDirectoryEntries(getter_AddRefs(subEntries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
// Now iterate over all the files in the subdir
|
||||
bool subHasMore = false;
|
||||
while(NS_SUCCEEDED(rv = subEntries->HasMoreElements(&subHasMore)) &&
|
||||
subHasMore) {
|
||||
nsCOMPtr<nsISupports> subEntry;
|
||||
rv = subEntries->GetNext(getter_AddRefs(subEntry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(subEntry);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while(NS_SUCCEEDED(rv = subEntries->GetNextFile(getter_AddRefs(file))) &&
|
||||
file) {
|
||||
nsAutoCString leafName;
|
||||
rv = file->GetNativeLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
@ -625,19 +613,12 @@ RemoveNsIFileRecursively(const QuotaInfo& aQuotaInfo, nsIFile* aFile)
|
||||
|
||||
// Unfortunately, we need to traverse all the entries and delete files one by
|
||||
// one to update their usages to the QuotaManager.
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aFile->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
bool hasMore = false;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
rv = RemoveNsIFileRecursively(aQuotaInfo, file);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
}
|
||||
|
28
dom/cache/QuotaClient.cpp
vendored
28
dom/cache/QuotaClient.cpp
vendored
@ -39,19 +39,13 @@ GetBodyUsage(nsIFile* aDir, const Atomic<bool>& aCanceled,
|
||||
{
|
||||
AssertIsOnIOThread();
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDir->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore &&
|
||||
!aCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) &&
|
||||
file && !aCanceled) {
|
||||
bool isDir;
|
||||
rv = file->IsDirectory(&isDir);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
@ -187,19 +181,13 @@ public:
|
||||
|
||||
aUsageInfo->AppendToFileUsage(paddingSize);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore &&
|
||||
!aCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) &&
|
||||
file && !aCanceled) {
|
||||
nsAutoString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
2
dom/cache/test/xpcshell/make_profile.js
vendored
2
dom/cache/test/xpcshell/make_profile.js
vendored
@ -19,7 +19,7 @@ function enumerate_tree(entryList) {
|
||||
if (file.isDirectory()) {
|
||||
var dirList = file.directoryEntries;
|
||||
while (dirList.hasMoreElements()) {
|
||||
var dirFile = dirList.getNext().QueryInterface(Ci.nsIFile);
|
||||
var dirFile = dirList.nextFile;
|
||||
entryList.push({ path: path + '/' + dirFile.leafName, file: dirFile });
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ GetDirectoryListingTaskParent::IOWork()
|
||||
return NS_ERROR_DOM_FILESYSTEM_TYPE_MISMATCH_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = mTargetPath->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -329,18 +329,10 @@ GetDirectoryListingTaskParent::IOWork()
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
bool hasMore = false;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->HasMoreElements(&hasMore))) || !hasMore) {
|
||||
nsCOMPtr<nsIFile> currFile;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->GetNextFile(getter_AddRefs(currFile)))) || !currFile) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->GetNext(getter_AddRefs(supp))))) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> currFile = do_QueryInterface(supp);
|
||||
MOZ_ASSERT(currFile);
|
||||
|
||||
bool isSpecial, isFile;
|
||||
if (NS_WARN_IF(NS_FAILED(currFile->IsSpecial(&isSpecial))) ||
|
||||
isSpecial) {
|
||||
|
@ -338,26 +338,17 @@ GetFilesHelperBase::ExploreDirectory(const nsAString& aDOMPath, nsIFile* aFile)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aFile->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
bool hasMore = false;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->HasMoreElements(&hasMore))) || !hasMore) {
|
||||
nsCOMPtr<nsIFile> currFile;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->GetNextFile(getter_AddRefs(currFile)))) || !currFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
if (NS_WARN_IF(NS_FAILED(entries->GetNext(getter_AddRefs(supp))))) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> currFile = do_QueryInterface(supp);
|
||||
MOZ_ASSERT(currFile);
|
||||
|
||||
bool isLink, isSpecial, isFile, isDir;
|
||||
if (NS_WARN_IF(NS_FAILED(currFile->IsSymlink(&isLink)) ||
|
||||
NS_FAILED(currFile->IsSpecial(&isSpecial))) ||
|
||||
|
@ -17404,7 +17404,7 @@ FileManager::GetUsage(nsIFile* aDirectory, uint64_t* aUsage)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -17412,17 +17412,8 @@ FileManager::GetUsage(nsIFile* aDirectory, uint64_t* aUsage)
|
||||
|
||||
uint64_t usage = 0;
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
nsString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -17984,7 +17975,7 @@ QuotaClient::GetDatabaseFilenames(
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(aDirectory);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -18000,19 +17991,10 @@ QuotaClient::GetDatabaseFilenames(
|
||||
const NS_ConvertASCIItoUTF16 walSuffix(kSQLiteWALSuffix,
|
||||
LiteralStringLength(kSQLiteWALSuffix));
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
|
||||
hasMore &&
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||
file &&
|
||||
!aCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -18087,7 +18069,7 @@ QuotaClient::GetUsageForDirectoryInternal(nsIFile* aDirectory,
|
||||
MOZ_ASSERT(aDirectory);
|
||||
MOZ_ASSERT(aUsageInfo);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -18103,19 +18085,10 @@ QuotaClient::GetUsageForDirectoryInternal(nsIFile* aDirectory,
|
||||
const NS_ConvertASCIItoUTF16 shmSuffix(kSQLiteSHMSuffix,
|
||||
LiteralStringLength(kSQLiteSHMSuffix));
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
|
||||
hasMore &&
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||
file &&
|
||||
!aCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -18438,7 +18411,7 @@ Maintenance::DirectoryWork()
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> persistenceDirEntries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> persistenceDirEntries;
|
||||
rv = persistenceDir->GetDirectoryEntries(
|
||||
getter_AddRefs(persistenceDirEntries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -18455,26 +18428,16 @@ Maintenance::DirectoryWork()
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
bool persistenceDirHasMoreEntries;
|
||||
rv = persistenceDirEntries->HasMoreElements(
|
||||
&persistenceDirHasMoreEntries);
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
rv = persistenceDirEntries->GetNextFile(getter_AddRefs(originDir));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!persistenceDirHasMoreEntries) {
|
||||
if (!originDir) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> persistenceDirEntry;
|
||||
rv = persistenceDirEntries->GetNext(getter_AddRefs(persistenceDirEntry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(persistenceDirEntry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
rv = originDir->Exists(&exists);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -18520,7 +18483,7 @@ Maintenance::DirectoryWork()
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> idbDirEntries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> idbDirEntries;
|
||||
rv = idbDir->GetDirectoryEntries(getter_AddRefs(idbDirEntries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -18541,25 +18504,16 @@ Maintenance::DirectoryWork()
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
bool idbDirHasMoreEntries;
|
||||
rv = idbDirEntries->HasMoreElements(&idbDirHasMoreEntries);
|
||||
nsCOMPtr<nsIFile> idbDirFile;
|
||||
rv = idbDirEntries->GetNextFile(getter_AddRefs(idbDirFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!idbDirHasMoreEntries) {
|
||||
if (!idbDirFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> idbDirEntry;
|
||||
rv = idbDirEntries->GetNext(getter_AddRefs(idbDirEntry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> idbDirFile = do_QueryInterface(idbDirEntry);
|
||||
MOZ_ASSERT(idbDirFile);
|
||||
|
||||
nsString idbFilePath;
|
||||
rv = idbDirFile->GetPath(idbFilePath);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -340,8 +340,7 @@ function getChromeFilesDir()
|
||||
|
||||
let idbEntries = idbDir.directoryEntries;
|
||||
while (idbEntries.hasMoreElements()) {
|
||||
let entry = idbEntries.getNext();
|
||||
let file = entry.QueryInterface(Ci.nsIFile);
|
||||
let file = idbEntries.nextFile;
|
||||
if (file.isDirectory()) {
|
||||
return file;
|
||||
}
|
||||
|
@ -44,25 +44,14 @@ template<typename T>
|
||||
static nsresult
|
||||
EnumerateDir(nsIFile* aPath, T&& aDirIter)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
nsresult rv = aPath->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore = false;
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = iter->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> entry(do_QueryInterface(supports, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> entry;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(entry))) && entry) {
|
||||
aDirIter(entry);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -2094,23 +2094,15 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
|
||||
|
||||
bool flashOnly = Preferences::GetBool("plugin.load_flash_only", true);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
rv = pluginsDir->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
AutoTArray<nsCOMPtr<nsIFile>, 6> pluginFiles;
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = iter->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
nsCOMPtr<nsIFile> dirEntry(do_QueryInterface(supports, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIFile> dirEntry;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(dirEntry))) && dirEntry) {
|
||||
// Sun's JRE 1.3.1 plugin must have symbolic links resolved or else it'll crash.
|
||||
// See bug 197855.
|
||||
dirEntry->Normalize();
|
||||
|
@ -1971,23 +1971,14 @@ GetLastModifiedTime(nsIFile* aFile, bool aPersistent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aFile->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
rv = GetLastModifiedTime(file, aTimestamp);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -4228,23 +4219,14 @@ QuotaManager::InitializeRepository(PersistenceType aPersistenceType)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> childDirectory = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(childDirectory);
|
||||
|
||||
nsCOMPtr<nsIFile> childDirectory;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(childDirectory)))) && childDirectory) {
|
||||
bool isDirectory;
|
||||
rv = childDirectory->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -4316,19 +4298,12 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
|
||||
usageInfo = new UsageInfo();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
NS_ENSURE_TRUE(file, NS_NOINTERFACE);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
bool isDirectory;
|
||||
rv = file->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -6738,20 +6713,13 @@ QuotaUsageRequestBase::GetUsageForOrigin(QuotaManager* aQuotaManager,
|
||||
initialized = aQuotaManager->IsTemporaryStorageInitialized();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
|
||||
hasMore && !mCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
NS_ENSURE_TRUE(file, NS_NOINTERFACE);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||
file && !mCanceled) {
|
||||
bool isDirectory;
|
||||
rv = file->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -6904,7 +6872,7 @@ GetUsageOp::TraverseRepository(QuotaManager* aQuotaManager,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -6912,18 +6880,9 @@ GetUsageOp::TraverseRepository(QuotaManager* aQuotaManager,
|
||||
|
||||
bool persistent = aPersistenceType == PERSISTENCE_TYPE_PERSISTENT;
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
|
||||
hasMore && !mCanceled) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(originDir)))) &&
|
||||
originDir && !mCanceled) {
|
||||
bool isDirectory;
|
||||
rv = originDir->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -7406,7 +7365,7 @@ ClearRequestBase::DeleteFiles(QuotaManager* aQuotaManager,
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
if (NS_WARN_IF(NS_FAILED(
|
||||
directory->GetDirectoryEntries(getter_AddRefs(entries)))) || !entries) {
|
||||
return;
|
||||
@ -7423,17 +7382,8 @@ ClearRequestBase::DeleteFiles(QuotaManager* aQuotaManager,
|
||||
originScope.SetPrefix(prefixSanitized);
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(file);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
bool isDirectory;
|
||||
rv = file->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -8576,23 +8526,15 @@ CreateOrUpgradeDirectoryMetadataHelper::CreateOrUpgradeMetadataFiles()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(originDir)))) &&
|
||||
originDir) {
|
||||
nsString leafName;
|
||||
rv = originDir->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -8742,25 +8684,15 @@ CreateOrUpgradeDirectoryMetadataHelper::MaybeUpgradeOriginDirectory(
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (NS_WARN_IF(!file)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||
file) {
|
||||
nsString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -8908,23 +8840,15 @@ UpgradeStorageFrom0_0To1_0Helper::DoUpgrade()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(originDir)))) &&
|
||||
originDir) {
|
||||
bool isDirectory;
|
||||
rv = originDir->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -9041,23 +8965,14 @@ UpgradeStorageFrom1_0To2_0Helper::DoUpgrade()
|
||||
MOZ_ASSERT(NS_SUCCEEDED(mDirectory->Exists(&exists)));
|
||||
MOZ_ASSERT(exists);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(originDir)))) && originDir) {
|
||||
bool isDirectory;
|
||||
rv = originDir->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -9153,26 +9068,15 @@ UpgradeStorageFrom1_0To2_0Helper::MaybeUpgradeClients(
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv =
|
||||
aOriginProps.mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (NS_WARN_IF(!file)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
bool isDirectory;
|
||||
rv = file->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -9379,23 +9283,14 @@ UpgradeStorageFrom2_0To2_1Helper::DoUpgrade()
|
||||
MOZ_ASSERT(NS_SUCCEEDED(mDirectory->Exists(&exists)));
|
||||
MOZ_ASSERT(exists);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> originDir = do_QueryInterface(entry);
|
||||
MOZ_ASSERT(originDir);
|
||||
|
||||
nsCOMPtr<nsIFile> originDir;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(originDir)))) && originDir) {
|
||||
bool isDirectory;
|
||||
rv = originDir->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -9483,26 +9378,15 @@ UpgradeStorageFrom2_0To2_1Helper::MaybeUpgradeClients(
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv =
|
||||
aOriginProps.mDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
rv = entries->GetNext(getter_AddRefs(entry));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (NS_WARN_IF(!file)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) && file) {
|
||||
bool isDirectory;
|
||||
rv = file->IsDirectory(&isDirectory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -1886,43 +1886,31 @@ void nsWebBrowserPersist::CleanupLocalFiles()
|
||||
// recursed through to ensure they are actually empty.
|
||||
|
||||
bool isEmptyDirectory = true;
|
||||
nsCOMArray<nsISimpleEnumerator> dirStack;
|
||||
nsCOMArray<nsIDirectoryEnumerator> dirStack;
|
||||
int32_t stackSize = 0;
|
||||
|
||||
// Push the top level enum onto the stack
|
||||
nsCOMPtr<nsISimpleEnumerator> pos;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> pos;
|
||||
if (NS_SUCCEEDED(file->GetDirectoryEntries(getter_AddRefs(pos))))
|
||||
dirStack.AppendObject(pos);
|
||||
|
||||
while (isEmptyDirectory && (stackSize = dirStack.Count()))
|
||||
{
|
||||
// Pop the last element
|
||||
nsCOMPtr<nsISimpleEnumerator> curPos;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> curPos;
|
||||
curPos = dirStack[stackSize-1];
|
||||
dirStack.RemoveObjectAt(stackSize - 1);
|
||||
|
||||
// Test if the enumerator has any more files in it
|
||||
bool hasMoreElements = false;
|
||||
curPos->HasMoreElements(&hasMoreElements);
|
||||
if (!hasMoreElements)
|
||||
nsCOMPtr<nsIFile> child;
|
||||
if (NS_FAILED(curPos->GetNextFile(getter_AddRefs(child))) || !child)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Child files automatically make this code drop out,
|
||||
// while child dirs keep the loop going.
|
||||
nsCOMPtr<nsISupports> child;
|
||||
curPos->GetNext(getter_AddRefs(child));
|
||||
NS_ASSERTION(child, "No child element, but hasMoreElements says otherwise");
|
||||
if (!child)
|
||||
continue;
|
||||
nsCOMPtr<nsIFile> childAsFile = do_QueryInterface(child);
|
||||
NS_ASSERTION(childAsFile, "This should be a file but isn't");
|
||||
|
||||
bool childIsSymlink = false;
|
||||
childAsFile->IsSymlink(&childIsSymlink);
|
||||
child->IsSymlink(&childIsSymlink);
|
||||
bool childIsDir = false;
|
||||
childAsFile->IsDirectory(&childIsDir);
|
||||
child->IsDirectory(&childIsDir);
|
||||
if (!childIsDir || childIsSymlink)
|
||||
{
|
||||
// Some kind of file or symlink which means dir
|
||||
@ -1931,8 +1919,8 @@ void nsWebBrowserPersist::CleanupLocalFiles()
|
||||
break;
|
||||
}
|
||||
// Push parent enumerator followed by child enumerator
|
||||
nsCOMPtr<nsISimpleEnumerator> childPos;
|
||||
childAsFile->GetDirectoryEntries(getter_AddRefs(childPos));
|
||||
nsCOMPtr<nsIDirectoryEnumerator> childPos;
|
||||
child->GetDirectoryEntries(getter_AddRefs(childPos));
|
||||
dirStack.AppendObject(curPos);
|
||||
if (childPos)
|
||||
dirStack.AppendObject(childPos);
|
||||
|
@ -421,15 +421,11 @@ mozHunspell::LoadDictionariesFromDir(nsIFile* aDir)
|
||||
if (NS_FAILED(rv) || !check)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = aDir->GetDirectoryEntries(getter_AddRefs(e));
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files;
|
||||
rv = aDir->GetDirectoryEntries(getter_AddRefs(files));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
|
||||
if (!files)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
nsAutoString leafName;
|
||||
|
@ -1162,22 +1162,14 @@ gfxGDIFontList::ActivateBundledFonts()
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> e;
|
||||
rv = localDir->GetDirectoryEntries(getter_AddRefs(e));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
if (NS_FAILED(e->GetNext(getter_AddRefs(entry)))) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(e->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
nsAutoString path;
|
||||
if (NS_FAILED(file->GetPath(path))) {
|
||||
continue;
|
||||
|
@ -251,17 +251,12 @@ nsHyphenationManager::LoadPatternListFromDir(nsIFile *aDir)
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = aDir->GetDirectoryEntries(getter_AddRefs(e));
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files;
|
||||
rv = aDir->GetDirectoryEntries(getter_AddRefs(files));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file){
|
||||
nsAutoString dictName;
|
||||
|
@ -511,32 +511,22 @@ ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile,
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
if (NS_FAILED(aFile->GetDirectoryEntries(getter_AddRefs(entries)))) {
|
||||
aAnnotation.AppendLiteral(" (failed to enumerated directory)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
bool hasMore = false;
|
||||
if (NS_FAILED(entries->HasMoreElements(&hasMore))) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_FAILED(entries->GetNextFile(getter_AddRefs(file)))) {
|
||||
aAnnotation.AppendLiteral(" (failed during directory enumeration)\n");
|
||||
return;
|
||||
}
|
||||
if (!hasMore) {
|
||||
if (!file) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
if (NS_FAILED(entries->GetNext(getter_AddRefs(entry)))) {
|
||||
aAnnotation.AppendLiteral(" (failed during directory enumeration)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
|
||||
if (file) {
|
||||
ListInterestingFiles(aAnnotation, file, aInterestingFilenames);
|
||||
}
|
||||
ListInterestingFiles(aAnnotation, file, aInterestingFilenames);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ function FindUnexpectedCrashDumpFiles()
|
||||
|
||||
let foundCrashDumpFile = false;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
let path = String(file.path);
|
||||
if (path.match(/\.(dmp|extra)$/) && !g.unexpectedCrashDumpFiles[path]) {
|
||||
if (!foundCrashDumpFile) {
|
||||
@ -1282,7 +1282,7 @@ function RemovePendingCrashDumpFiles()
|
||||
|
||||
let entries = g.pendingCrashDumpDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
if (file.isFile()) {
|
||||
file.remove(false);
|
||||
logger.info("This test left pending crash dumps; deleted "+file.path);
|
||||
|
@ -20,7 +20,7 @@ function AddToZip(zipWriter, path, file)
|
||||
if (file.isDirectory()) {
|
||||
var entries = file.QueryInterface(Ci.nsIFile).directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
var entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
var entry = entries.nextFile;
|
||||
AddToZip(zipWriter, currentPath, entry);
|
||||
}
|
||||
}
|
||||
|
@ -3987,9 +3987,8 @@ pref_LoadPrefsInDir(nsIFile* aDir,
|
||||
uint32_t aSpecialFilesCount)
|
||||
{
|
||||
nsresult rv, rv2;
|
||||
bool hasMoreElements;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> dirIterator;
|
||||
|
||||
// This may fail in some normal cases, such as embedders who do not use a
|
||||
// GRE.
|
||||
@ -4004,21 +4003,12 @@ pref_LoadPrefsInDir(nsIFile* aDir,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = dirIterator->HasMoreElements(&hasMoreElements);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMArray<nsIFile> prefFiles(INITIAL_PREF_FILES);
|
||||
nsCOMArray<nsIFile> specialFiles(aSpecialFilesCount);
|
||||
nsCOMPtr<nsIFile> prefFile;
|
||||
|
||||
while (hasMoreElements && NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = dirIterator->GetNext(getter_AddRefs(supports));
|
||||
prefFile = do_QueryInterface(supports);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (NS_SUCCEEDED(dirIterator->GetNextFile(getter_AddRefs(prefFile))) &&
|
||||
prefFile) {
|
||||
nsAutoCString leafName;
|
||||
prefFile->GetNativeLeafName(leafName);
|
||||
MOZ_ASSERT(
|
||||
@ -4045,8 +4035,6 @@ pref_LoadPrefsInDir(nsIFile* aDir,
|
||||
prefFiles.AppendObject(prefFile);
|
||||
}
|
||||
}
|
||||
|
||||
rv = dirIterator->HasMoreElements(&hasMoreElements);
|
||||
}
|
||||
|
||||
if (prefFiles.Count() + specialFiles.Count() == 0) {
|
||||
|
@ -96,7 +96,7 @@ nsDirectoryIndexStream::Init(nsIFile* aDir)
|
||||
|
||||
// Sigh. We have to allocate on the heap because there are no
|
||||
// assignment operators defined.
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
rv = aDir->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -104,15 +104,9 @@ nsDirectoryIndexStream::Init(nsIFile* aDir)
|
||||
// XXX - should we do so here, or when the first item is requested?
|
||||
// XXX - use insertion sort instead?
|
||||
|
||||
bool more;
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&more)) && more) {
|
||||
rv = iter->GetNext(getter_AddRefs(elem));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(elem);
|
||||
if (file)
|
||||
mArray.AppendObject(file); // addrefs
|
||||
}
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
mArray.AppendObject(file); // addrefs
|
||||
}
|
||||
|
||||
#ifdef THREADSAFE_I18N
|
||||
|
34
netwerk/cache/nsDeleteDir.cpp
vendored
34
netwerk/cache/nsDeleteDir.cpp
vendored
@ -332,24 +332,15 @@ nsDeleteDir::RemoveOldTrashes(nsIFile *cacheDir)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
rv = parent->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
bool more;
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
nsAutoPtr<nsCOMArray<nsIFile> > dirList;
|
||||
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&more)) && more) {
|
||||
rv = iter->GetNext(getter_AddRefs(elem));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(elem);
|
||||
if (!file)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
nsAutoString leafName;
|
||||
rv = file->GetLeafName(leafName);
|
||||
if (NS_FAILED(rv))
|
||||
@ -416,26 +407,13 @@ nsDeleteDir::RemoveDir(nsIFile *file, bool *stopDeleting)
|
||||
return rv;
|
||||
|
||||
if (isDir) {
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
rv = file->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
bool more;
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&more)) && more) {
|
||||
rv = iter->GetNext(getter_AddRefs(elem));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Unexpected failure in nsDeleteDir::RemoveDir");
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file2 = do_QueryInterface(elem);
|
||||
if (!file2) {
|
||||
NS_WARNING("Unexpected failure in nsDeleteDir::RemoveDir");
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file2;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(file2))) && file2) {
|
||||
RemoveDir(file2, stopDeleting);
|
||||
// No check for errors to remove as much as possible
|
||||
|
||||
|
@ -340,13 +340,8 @@ CacheFileContextEvictor::LoadEvictInfoFromDisk()
|
||||
|
||||
sDiskAlreadySearched = true;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = mCacheDirectory->GetDirectoryEntries(getter_AddRefs(enumerator));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> dirEnum = do_QueryInterface(enumerator, &rv);
|
||||
nsCOMPtr<nsIDirectoryEnumerator> dirEnum;
|
||||
rv = mCacheDirectory->GetDirectoryEntries(getter_AddRefs(dirEnum));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -3496,12 +3496,8 @@ CacheFileIOManager::RemoveTrashInternal()
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = mTrashDir->GetDirectoryEntries(getter_AddRefs(enumerator));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mTrashDirEnumerator = do_QueryInterface(enumerator, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = mTrashDir->GetDirectoryEntries(getter_AddRefs(mTrashDirEnumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
continue; // check elapsed time
|
||||
}
|
||||
@ -3561,24 +3557,12 @@ CacheFileIOManager::FindTrashDirToRemove()
|
||||
// remove all cache files.
|
||||
MOZ_ASSERT(mIOThread->IsCurrentThread() || mShuttingDown);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> iter;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> iter;
|
||||
rv = mCacheDirectory->GetDirectoryEntries(getter_AddRefs(iter));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool more;
|
||||
nsCOMPtr<nsISupports> elem;
|
||||
|
||||
while (NS_SUCCEEDED(iter->HasMoreElements(&more)) && more) {
|
||||
rv = iter->GetNext(getter_AddRefs(elem));
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(elem);
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
bool isDir = false;
|
||||
file->IsDirectory(&isDir);
|
||||
if (!isDir) {
|
||||
|
@ -2688,11 +2688,7 @@ CacheIndex::SetupDirectoryEnumerator()
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = file->GetDirectoryEntries(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDirEnumerator = do_QueryInterface(enumerator, &rv);
|
||||
rv = file->GetDirectoryEntries(getter_AddRefs(mDirEnumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2101,7 +2101,7 @@ function defaultIndexHandler(metadata, response)
|
||||
var files = directory.directoryEntries;
|
||||
while (files.hasMoreElements())
|
||||
{
|
||||
var f = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
var f = files.nextFile;
|
||||
var name = f.leafName;
|
||||
if (!f.isHidden() &&
|
||||
(name.charAt(name.length - 1) != HIDDEN_CHAR ||
|
||||
|
@ -759,7 +759,7 @@ Tester.prototype = {
|
||||
if (gdir.exists()) {
|
||||
let entries = gdir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
if (entry.isFile()) {
|
||||
let msg = "this test left a pending crash report; ";
|
||||
try {
|
||||
|
@ -381,8 +381,7 @@ function serverDebug(metadata, response) {
|
||||
function* dirIter(dir) {
|
||||
var en = dir.directoryEntries;
|
||||
while (en.hasMoreElements()) {
|
||||
var file = en.getNext();
|
||||
yield file.QueryInterface(Ci.nsIFile);
|
||||
yield en.nextFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
|
||||
var crashDumpFiles = [];
|
||||
while (entries.hasMoreElements()) {
|
||||
var file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
var file = entries.nextFile;
|
||||
var path = String(file.path);
|
||||
if (path.match(/\.(dmp|extra)$/) && !aToIgnore[path]) {
|
||||
crashDumpFiles.push(path);
|
||||
@ -195,7 +195,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
if (crashDumpDir.exists()) {
|
||||
let entries = crashDumpDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
if (file.isFile()) {
|
||||
file.remove(false);
|
||||
removed = true;
|
||||
|
@ -34,7 +34,7 @@ function setup() {
|
||||
|
||||
let entries = downloadDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
ok(false, `Leftover file ${entry.path} in download directory`);
|
||||
entry.remove(false);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ function setup() {
|
||||
|
||||
let entries = downloadDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
ok(false, `Leftover file ${entry.path} in download directory`);
|
||||
entry.remove(false);
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ function iterateDir(dir, recurse, callback) {
|
||||
|
||||
// Loop over everything in this dir. If its a dir
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext();
|
||||
entry.QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (recurse) {
|
||||
|
@ -116,7 +116,7 @@ var reference_dir_contents = function reference_dir_contents(path) {
|
||||
let result = [];
|
||||
let entries = new FileUtils.File(path).directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = entries.nextFile;
|
||||
result.push(entry.path);
|
||||
}
|
||||
return result;
|
||||
|
@ -10,7 +10,7 @@ add_task(async function test_json_backup_in_future() {
|
||||
// Remove all files from backups folder.
|
||||
let files = bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
let entry = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = files.nextFile;
|
||||
entry.remove(false);
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ add_task(async function test_json_backup_in_future() {
|
||||
Assert.equal(name, "bookmarks-" + PlacesBackups.toISODateString(dateObj) + ".json");
|
||||
files = bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
let entry = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = files.nextFile;
|
||||
if (PlacesBackups.filenamesRegex.test(entry.leafName))
|
||||
entry.remove(false);
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ function check_JSON_backup(aIsAutomaticBackup) {
|
||||
bookmarksBackupDir.append("bookmarkbackups");
|
||||
let files = bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
let entry = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = files.nextFile;
|
||||
if (PlacesBackups.filenamesRegex.test(entry.leafName)) {
|
||||
profileBookmarksJSONFile = entry;
|
||||
break;
|
||||
|
@ -55,7 +55,7 @@ add_task(async function() {
|
||||
if (i > 0) {
|
||||
let files = bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
let entry = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = files.nextFile;
|
||||
if (PlacesBackups.filenamesRegex.test(entry.leafName)) {
|
||||
backupFilename = entry.leafName;
|
||||
backupFile = entry;
|
||||
@ -78,7 +78,7 @@ add_task(async function() {
|
||||
// on WIN XP.
|
||||
let files = bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
let entry = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = files.nextFile;
|
||||
entry.remove(false);
|
||||
}
|
||||
Assert.ok(!bookmarksBackupDir.directoryEntries.hasMoreElements());
|
||||
|
@ -2849,10 +2849,11 @@ SearchService.prototype = {
|
||||
// NS_APP_DISTRIBUTION_SEARCH_DIR_LIST is defined by each app
|
||||
// so this throws during unit tests (but not xpcshell tests).
|
||||
locations = {hasMoreElements: () => false};
|
||||
|
||||
}
|
||||
while (locations.hasMoreElements()) {
|
||||
let dir = locations.getNext().QueryInterface(Ci.nsIFile);
|
||||
if (dir.directoryEntries.hasMoreElements())
|
||||
if (dir.directoryEntries.nextFile)
|
||||
distDirs.push(dir);
|
||||
}
|
||||
|
||||
@ -3207,12 +3208,9 @@ SearchService.prototype = {
|
||||
_loadEnginesFromDir: function SRCH_SVC__loadEnginesFromDir(aDir) {
|
||||
LOG("_loadEnginesFromDir: Searching in " + aDir.path + " for search engines.");
|
||||
|
||||
var files = aDir.directoryEntries
|
||||
.QueryInterface(Ci.nsIDirectoryEnumerator);
|
||||
|
||||
while (files.hasMoreElements()) {
|
||||
var file = files.nextFile;
|
||||
|
||||
var files = aDir.directoryEntries;
|
||||
var file;
|
||||
while ((file = files.nextFile)) {
|
||||
// Ignore hidden and empty files, and directories
|
||||
if (!file.isFile() || file.fileSize == 0 || file.isHidden())
|
||||
continue;
|
||||
|
@ -1100,12 +1100,8 @@ ReadStack(PathCharPtr aFileName, Telemetry::ProcessedStack &aStack)
|
||||
void
|
||||
TelemetryImpl::ReadLateWritesStacks(nsIFile* aProfileDir)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
if (NS_FAILED(aProfileDir->GetDirectoryEntries(getter_AddRefs(e)))) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
|
||||
if (!files) {
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files;
|
||||
if (NS_FAILED(aProfileDir->GetDirectoryEntries(getter_AddRefs(files)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -333,19 +333,12 @@ Classifier::ResetTables(ClearType aType, const nsTArray<nsCString>& aTables)
|
||||
void
|
||||
Classifier::DeleteTables(nsIFile* aDirectory, const nsTArray<nsCString>& aTables)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = entries->GetNext(getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
|
||||
NS_ENSURE_TRUE_VOID(file);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
// If |file| is a directory, recurse to find its entries as well.
|
||||
bool isDirectory;
|
||||
if (NS_FAILED(file->IsDirectory(&isDirectory))) {
|
||||
@ -970,18 +963,12 @@ Classifier::RegenActiveTables()
|
||||
nsresult
|
||||
Classifier::ScanStoreDir(nsIFile* aDirectory, nsTArray<nsCString>& aTables)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = entries->GetNext(getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
// If |file| is a directory, recurse to find its entries as well.
|
||||
bool isDirectory;
|
||||
if (NS_FAILED(file->IsDirectory(&isDirectory))) {
|
||||
@ -1564,19 +1551,13 @@ Classifier::ReadNoiseEntries(const Prefix& aPrefix,
|
||||
nsresult
|
||||
Classifier::LoadMetadata(nsIFile* aDirectory, nsACString& aResult)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
nsresult rv = aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_ARG_POINTER(entries);
|
||||
|
||||
bool hasMore;
|
||||
while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = entries->GetNext(getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
// If |file| is a directory, recurse to find its entries as well.
|
||||
bool isDirectory;
|
||||
if (NS_FAILED(file->IsDirectory(&isDirectory))) {
|
||||
|
@ -26,8 +26,7 @@ function* dirIter(directory) {
|
||||
|
||||
let en = testsDir.directoryEntries;
|
||||
while (en.hasMoreElements()) {
|
||||
let file = en.getNext();
|
||||
yield file.QueryInterface(Ci.nsIFile);
|
||||
yield en.nextFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ var CrashReports = {
|
||||
if (this.submittedDir.exists() && this.submittedDir.isDirectory()) {
|
||||
let entries = this.submittedDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
let leaf = file.leafName;
|
||||
if (leaf.startsWith("bp-") &&
|
||||
leaf.endsWith(".txt")) {
|
||||
@ -42,7 +42,7 @@ var CrashReports = {
|
||||
let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
let entries = this.pendingDir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
let leaf = file.leafName;
|
||||
let id = leaf.slice(0, -4);
|
||||
if (leaf.endsWith(".dmp") && uuidRegex.test(id)) {
|
||||
|
@ -108,7 +108,7 @@ add_task(async function test() {
|
||||
for (let dir of dirs) {
|
||||
let entries = dir.directoryEntries;
|
||||
while (entries.hasMoreElements()) {
|
||||
let file = entries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = entries.nextFile;
|
||||
let index = existing.indexOf(file.path);
|
||||
isnot(index, -1, file.leafName + " exists");
|
||||
|
||||
|
@ -90,7 +90,7 @@ function do_crash(setup, callback, canReturnZero) {
|
||||
function getMinidump() {
|
||||
let en = do_get_tempdir().directoryEntries;
|
||||
while (en.hasMoreElements()) {
|
||||
let f = en.getNext().QueryInterface(Ci.nsIFile);
|
||||
let f = en.nextFile;
|
||||
if (f.leafName.substr(-4) == ".dmp") {
|
||||
return f;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ function dir_entries(baseDir, subpath, ext) {
|
||||
}
|
||||
var entries = [];
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
var file = enumerator.nextFile;
|
||||
if (file.isDirectory()) {
|
||||
entries = entries.concat(dir_entries(dir, file.leafName, ext).map(p => subpath + "/" + p));
|
||||
} else if (endsWith(file.leafName, ext)) {
|
||||
|
@ -338,7 +338,7 @@ function hasUpdateMutex() {
|
||||
function areDirectoryEntriesWriteable(aDir) {
|
||||
let items = aDir.directoryEntries;
|
||||
while (items.hasMoreElements()) {
|
||||
let item = items.getNext().QueryInterface(Ci.nsIFile);
|
||||
let item = items.nextFile;
|
||||
if (!item.isWritable()) {
|
||||
LOG("areDirectoryEntriesWriteable - unable to write to " + item.path);
|
||||
return false;
|
||||
@ -815,7 +815,7 @@ function cleanUpUpdatesDir(aRemovePatchFiles = true) {
|
||||
if (aRemovePatchFiles) {
|
||||
let dirEntries = updateDir.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
let file = dirEntries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let file = dirEntries.nextFile;
|
||||
// Now, recursively remove this file. The recursive removal is needed for
|
||||
// Mac OSX because this directory will contain a copy of updater.app,
|
||||
// which is itself a directory and the MozUpdater directory on platforms
|
||||
|
@ -452,7 +452,7 @@ function cleanUpdatesDir(aDir) {
|
||||
|
||||
let dirEntries = aDir.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
let entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = dirEntries.nextFile;
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.leafName == DIR_PATCH && entry.parent.leafName == DIR_UPDATES) {
|
||||
@ -510,7 +510,7 @@ function removeDirRecursive(aDir) {
|
||||
|
||||
let dirEntries = aDir.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
let entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = dirEntries.nextFile;
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
removeDirRecursive(entry);
|
||||
|
@ -3673,7 +3673,7 @@ function checkFilesInDirRecursive(aDir, aCallback) {
|
||||
|
||||
let dirEntries = aDir.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
let entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
|
||||
let entry = dirEntries.nextFile;
|
||||
|
||||
if (entry.exists()) {
|
||||
if (entry.isDirectory()) {
|
||||
|
@ -55,7 +55,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1123480
|
||||
}
|
||||
var count = 0;
|
||||
for (var de = dir.directoryEntries; de.hasMoreElements(); ) {
|
||||
var fdFile = de.getNext().QueryInterface(Ci.nsIFile);
|
||||
var fdFile = de.nextFile;
|
||||
var fileSize;
|
||||
try {
|
||||
fileSize = fdFile.fileSize;
|
||||
|
@ -60,7 +60,7 @@
|
||||
dir.initWithPath("/dev/fd");
|
||||
var count = 0;
|
||||
for (var de = dir.directoryEntries; de.hasMoreElements(); ) {
|
||||
var fdFile = de.getNext().QueryInterface(Ci.nsIFile);
|
||||
var fdFile = de.nextFile;
|
||||
var fileSize;
|
||||
try {
|
||||
fileSize = fdFile.fileSize;
|
||||
|
@ -275,21 +275,17 @@ nsresult JumpListBuilder::RemoveIconCacheForAllItems()
|
||||
rv = jumpListCacheDir->AppendNative(nsDependentCString(
|
||||
mozilla::widget::FaviconHelper::kJumpListCacheDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = jumpListCacheDir->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Loop through each directory entry and remove all ICO files found
|
||||
do {
|
||||
bool hasMore = false;
|
||||
if (NS_FAILED(entries->HasMoreElements(&hasMore)) || !hasMore)
|
||||
nsCOMPtr<nsIFile> currFile;
|
||||
if (NS_FAILED(entries->GetNextFile(getter_AddRefs(currFile))) || !currFile)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
if (NS_FAILED(entries->GetNext(getter_AddRefs(supp))))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIFile> currFile(do_QueryInterface(supp));
|
||||
nsAutoString path;
|
||||
if (NS_FAILED(currFile->GetPath(path)))
|
||||
continue;
|
||||
|
@ -1464,21 +1464,18 @@ NS_IMETHODIMP AsyncDeleteAllFaviconsFromDisk::Run()
|
||||
nsresult rv = mJumpListCacheDir->AppendNative(
|
||||
nsDependentCString(FaviconHelper::kJumpListCacheDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsISimpleEnumerator> entries;
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
||||
rv = mJumpListCacheDir->GetDirectoryEntries(getter_AddRefs(entries));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Loop through each directory entry and remove all ICO files found
|
||||
do {
|
||||
bool hasMore = false;
|
||||
if (NS_FAILED(entries->HasMoreElements(&hasMore)) || !hasMore)
|
||||
nsCOMPtr<nsIFile> currFile;
|
||||
if (NS_FAILED(entries->GetNextFile(getter_AddRefs(currFile))) ||
|
||||
!currFile)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
if (NS_FAILED(entries->GetNext(getter_AddRefs(supp))))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIFile> currFile(do_QueryInterface(supp));
|
||||
nsAutoString path;
|
||||
if (NS_FAILED(currFile->GetPath(path)))
|
||||
continue;
|
||||
|
@ -729,20 +729,13 @@ nsLocalFile::CopyDirectoryTo(nsIFile* aNewParent)
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
nsCOMPtr<nsIDirectoryEnumerator> dirIterator;
|
||||
if (NS_FAILED(rv = GetDirectoryEntries(getter_AddRefs(dirIterator)))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool hasMore = false;
|
||||
while (NS_SUCCEEDED(dirIterator->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIFile> entry;
|
||||
rv = dirIterator->GetNext(getter_AddRefs(supports));
|
||||
entry = do_QueryInterface(supports);
|
||||
if (NS_FAILED(rv) || !entry) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<nsIFile> entry;
|
||||
while (NS_SUCCEEDED(dirIterator->GetNextFile(getter_AddRefs(entry))) && entry) {
|
||||
if (NS_FAILED(rv = entry->IsSymlink(&isSymlink))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -2010,36 +2010,30 @@ nsLocalFile::CopyMove(nsIFile* aParentDir, const nsAString& aNewName,
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool more = false;
|
||||
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&more)) && more) {
|
||||
nsCOMPtr<nsISupports> item;
|
||||
nsCOMPtr<nsIFile> file;
|
||||
dirEnum->GetNext(getter_AddRefs(item));
|
||||
file = do_QueryInterface(item);
|
||||
if (file) {
|
||||
bool isDir, isLink;
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(dirEnum->GetNextFile(getter_AddRefs(file))) && file) {
|
||||
bool isDir, isLink;
|
||||
|
||||
file->IsDirectory(&isDir);
|
||||
file->IsSymlink(&isLink);
|
||||
file->IsDirectory(&isDir);
|
||||
file->IsSymlink(&isLink);
|
||||
|
||||
if (move) {
|
||||
if (followSymlinks) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (move) {
|
||||
if (followSymlinks) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = file->MoveTo(target, EmptyString());
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = file->MoveTo(target, EmptyString());
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
if (followSymlinks) {
|
||||
rv = file->CopyToFollowingLinks(target, EmptyString());
|
||||
} else {
|
||||
if (followSymlinks) {
|
||||
rv = file->CopyToFollowingLinks(target, EmptyString());
|
||||
} else {
|
||||
rv = file->CopyTo(target, EmptyString());
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = file->CopyTo(target, EmptyString());
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ function run_test() {
|
||||
var drives = root.directoryEntries;
|
||||
Assert.ok(drives.hasMoreElements());
|
||||
while (drives.hasMoreElements()) {
|
||||
var newPath = drives.getNext().QueryInterface(nsIFile).path;
|
||||
var newPath = drives.nextFile.path;
|
||||
Assert.equal(newPath.indexOf("\0"), -1);
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ function testSymLinks(testDir, relative) {
|
||||
print(spaces + " dir file symlink");
|
||||
var dirEntries = testDir.directoryEntries;
|
||||
while (dirEntries.hasMoreElements()) {
|
||||
const file = dirEntries.getNext().QueryInterface(nsIFile);
|
||||
const file = dirEntries.nextFile;
|
||||
const name = file.leafName;
|
||||
print(name + spaces.substring(name.length) + bools[file.isDirectory()] +
|
||||
bools[file.isFile()] + bools[file.isSymlink()]);
|
||||
|
Loading…
Reference in New Issue
Block a user