Allow null as a destination file name argument for CopyTo in nsLocalFileOSX. b=478549 r=mbanner sr=roc

This commit is contained in:
Josh Aas 2009-02-15 19:20:27 -05:00
parent af1a76731a
commit 018ca06ce3

View File

@ -2227,11 +2227,15 @@ nsresult nsLocalFile::CopyInternal(nsIFile* aParentDir,
if (NS_FAILED(rv))
return rv;
CFStringRef destNameStr = ::CFStringCreateWithCharacters(kCFAllocatorDefault,
PromiseFlatString(newName).get(),
newName.Length());
CFStringRef destNameStr = NULL;
if (newName.Length() > 0) {
destNameStr = ::CFStringCreateWithCharacters(kCFAllocatorDefault,
PromiseFlatString(newName).get(),
newName.Length());
}
err = ::FSCopyObjectSync(&srcFSRef, &destFSRef, destNameStr, NULL, kFSFileOperationDefaultOptions);
::CFRelease(destNameStr);
if (destNameStr)
::CFRelease(destNameStr);
return MacErrorMapper(err);