Bug 1323935 - Entries API must use NS_NewLocalFile instead of NS_NewNativeLocalFile, r=smaug

This commit is contained in:
Andrea Marchesini 2017-01-18 04:48:29 +01:00
parent 5b50a98ca0
commit c980b8d524
10 changed files with 36 additions and 42 deletions

View File

@ -319,8 +319,10 @@ DataTransferItem::GetAsEntry(nsIPrincipal& aSubjectPrincipal,
}
nsCOMPtr<nsIFile> directoryFile;
nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(fullpath),
true, getter_AddRefs(directoryFile));
// fullPath is already in unicode, we don't have to use
// NS_NewNativeLocalFile.
nsresult rv = NS_NewLocalFile(fullpath, true,
getter_AddRefs(directoryFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}

View File

@ -98,9 +98,8 @@ CreateDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue&
const FileSystemDirectoryResponse& r =
aValue.get_FileSystemDirectoryResponse();
aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(r.realPath()), true,
getter_AddRefs(mTargetPath));
NS_WARNING_ASSERTION(!aRv.Failed(), "NS_NewNativeLocalFile failed");
aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
NS_WARNING_ASSERTION(!aRv.Failed(), "NS_NewLocalFile failed");
}
void
@ -149,8 +148,8 @@ CreateDirectoryTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<CreateDirectoryTaskParent> task =
new CreateDirectoryTaskParent(aFileSystem, aParam, aParent);
aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aParam.realPath()), true,
getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.realPath(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -140,8 +140,7 @@ CreateFileTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aVal
const FileSystemFileResponse& r = aValue.get_FileSystemFileResponse();
NS_ConvertUTF16toUTF8 path(r.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -194,8 +193,8 @@ CreateFileTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<CreateFileTaskParent> task =
new CreateFileTaskParent(aFileSystem, aParam, aParent);
NS_ConvertUTF16toUTF8 path(aParam.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.realPath(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -100,8 +100,8 @@ Directory::GetRoot(FileSystemBase* aFileSystem, ErrorResult& aRv)
MOZ_ASSERT(aFileSystem);
nsCOMPtr<nsIFile> path;
aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aFileSystem->LocalOrDeviceStorageRootPath()),
true, getter_AddRefs(path));
aRv = NS_NewLocalFile(aFileSystem->LocalOrDeviceStorageRootPath(),
true, getter_AddRefs(path));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
@ -122,8 +122,7 @@ Directory::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsIFile> path;
aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aRealPath),
true, getter_AddRefs(path));
aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -88,8 +88,7 @@ FileSystemBase::GetRealPath(BlobImpl* aFile, nsIFile** aPath) const
return false;
}
rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(filePath),
true, aPath);
rv = NS_NewLocalFile(filePath, true, aPath);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return false;
@ -134,8 +133,8 @@ FileSystemBase::GetDOMPath(nsIFile* aFile,
aRetval.Truncate();
nsCOMPtr<nsIFile> fileSystemPath;
aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(LocalOrDeviceStorageRootPath()),
true, getter_AddRefs(fileSystemPath));
aRv = NS_NewLocalFile(LocalOrDeviceStorageRootPath(),
true, getter_AddRefs(fileSystemPath));
if (NS_WARN_IF(aRv.Failed())) {
return;
}

View File

@ -166,8 +166,8 @@ GetDirectoryListingTaskChild::HandlerCallback()
for (unsigned i = 0; i < count; i++) {
nsCOMPtr<nsIFile> path;
NS_ConvertUTF16toUTF8 fullPath(mTargetData[i].mPath);
nsresult rv = NS_NewNativeLocalFile(fullPath, true, getter_AddRefs(path));
nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, true,
getter_AddRefs(path));
if (NS_WARN_IF(NS_FAILED(rv))) {
mPromise->MaybeReject(rv);
mPromise = nullptr;
@ -246,8 +246,8 @@ GetDirectoryListingTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<GetDirectoryListingTaskParent> task =
new GetDirectoryListingTaskParent(aFileSystem, aParam, aParent);
NS_ConvertUTF16toUTF8 path(aParam.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.realPath(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -100,8 +100,7 @@ GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseVal
case FileSystemResponseValue::TFileSystemFileResponse: {
FileSystemFileResponse r = aValue;
NS_ConvertUTF16toUTF8 path(r.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -112,8 +111,7 @@ GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseVal
case FileSystemResponseValue::TFileSystemDirectoryResponse: {
FileSystemDirectoryResponse r = aValue;
NS_ConvertUTF16toUTF8 path(r.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -183,8 +181,8 @@ GetFileOrDirectoryTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<GetFileOrDirectoryTaskParent> task =
new GetFileOrDirectoryTaskParent(aFileSystem, aParam, aParent);
NS_ConvertUTF16toUTF8 path(aParam.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.realPath(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -271,8 +271,7 @@ GetFilesHelper::RunIO()
MOZ_ASSERT(!mListingCompleted);
nsCOMPtr<nsIFile> file;
mErrorResult = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(mDirectoryPath), true,
getter_AddRefs(file));
mErrorResult = NS_NewLocalFile(mDirectoryPath, true, getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
return;
}
@ -306,8 +305,8 @@ GetFilesHelper::RunMainThread()
for (uint32_t i = 0; i < mTargetPathArray.Length(); ++i) {
nsCOMPtr<nsIFile> file;
mErrorResult =
NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(mTargetPathArray[i].mRealPath),
true, getter_AddRefs(file));
NS_NewLocalFile(mTargetPathArray[i].mRealPath, true,
getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
mFiles.Clear();
return;

View File

@ -154,8 +154,8 @@ GetFilesTaskChild::HandlerCallback()
for (unsigned i = 0; i < count; i++) {
nsCOMPtr<nsIFile> path;
NS_ConvertUTF16toUTF8 fullPath(mTargetData[i].mRealPath);
nsresult rv = NS_NewNativeLocalFile(fullPath, true, getter_AddRefs(path));
nsresult rv = NS_NewLocalFile(mTargetData[i].mRealPath, true,
getter_AddRefs(path));
if (NS_WARN_IF(NS_FAILED(rv))) {
mPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
mPromise = nullptr;
@ -210,8 +210,8 @@ GetFilesTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<GetFilesTaskParent> task =
new GetFilesTaskParent(aFileSystem, aParam, aParent);
NS_ConvertUTF16toUTF8 path(aParam.realPath());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.realPath(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}

View File

@ -162,17 +162,16 @@ RemoveTaskParent::Create(FileSystemBase* aFileSystem,
RefPtr<RemoveTaskParent> task =
new RemoveTaskParent(aFileSystem, aParam, aParent);
NS_ConvertUTF16toUTF8 directoryPath(aParam.directory());
aRv = NS_NewNativeLocalFile(directoryPath, true,
getter_AddRefs(task->mDirPath));
aRv = NS_NewLocalFile(aParam.directory(), true,
getter_AddRefs(task->mDirPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
task->mRecursive = aParam.recursive();
NS_ConvertUTF16toUTF8 path(aParam.targetDirectory());
aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
aRv = NS_NewLocalFile(aParam.targetDirectory(), true,
getter_AddRefs(task->mTargetPath));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}