From 38f65972b75951c30a49c8ec68eba81578cb6daa Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Tue, 22 Mar 2022 00:28:22 +0000 Subject: [PATCH] Bug 1722777 - Pre: Reuse existing directory iteration function when deleting folder content on Windows. r=nalexander Depends on D140428 Differential Revision: https://phabricator.services.mozilla.com/D140910 --- xpcom/io/nsLocalFileWin.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index e360b097d209..9207cf0f857b 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -2315,14 +2315,9 @@ nsLocalFile::Remove(bool aRecursive) { return rv; } - bool more = false; - while (NS_SUCCEEDED(dirEnum->HasMoreElements(&more)) && more) { - nsCOMPtr item; - dirEnum->GetNext(getter_AddRefs(item)); - nsCOMPtr file = do_QueryInterface(item); - if (file) { - file->Remove(aRecursive); - } + nsCOMPtr file; + while (NS_SUCCEEDED(dirEnum->GetNextFile(getter_AddRefs(file))) && file) { + file->Remove(aRecursive); } } if (RemoveDirectoryW(mWorkingPath.get()) == 0) {