Bug 872238 - After CreateUnique(), append file leaf name to dsf.mPath, not dsf.mFile.mPath, r=dhylands

This is a followup to bug 858416.
This commit is contained in:
Eric Chou 2013-05-15 16:53:45 +08:00
Родитель 4be181127d
Коммит 536fafeb07
1 изменённых файлов: 9 добавлений и 8 удалений

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

@ -750,16 +750,17 @@ DeviceStorageFile::CreateUnique(nsAString& aFileName,
NS_ENSURE_SUCCESS(rv, nullptr);
// CreateUnique may cause the filename to change. So we need to update mPath to reflect that.
int32_t lastSlashIndex = dsf->mPath.RFindChar('/');
if (lastSlashIndex == kNotFound) {
dsf->mPath.AssignLiteral("");
} else {
dsf->mPath = Substring(dsf->mPath, 0, lastSlashIndex);
}
nsString leafName;
dsf->mFile->GetLeafName(leafName);
dsf->AppendRelativePath(leafName);
int32_t lastSlashIndex = dsf->mPath.RFindChar('/');
if (lastSlashIndex == kNotFound) {
dsf->mPath.Assign(leafName);
} else {
// Include the last '/'
dsf->mPath = Substring(dsf->mPath, 0, lastSlashIndex + 1);
dsf->mPath.Append(leafName);
}
return dsf.forget();
}