a=leaf. 24996. We were not able to download files via save as because the destination file did not exist

This commit is contained in:
valeski%netscape.com 2000-01-25 22:44:39 +00:00
Родитель 19afa18999
Коммит ebef130835
2 изменённых файлов: 24 добавлений и 1 удалений

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

@ -54,4 +54,5 @@ interface nsIStreamTransferOperation : nsISupports {
const unsigned long kOpOutputClose = 8;
const unsigned long kOpOutputCancel = 9;
const unsigned long kOpRead = 10;
const unsigned long kOpCreateFile = 11;
};

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

@ -164,9 +164,31 @@ nsStreamXferOp::Start( void ) {
mOutputSpec->GetFileSpec( &target );
nsCOMPtr<nsILocalFile> file;
rv = NS_NewLocalFile(target, getter_AddRefs(file));
if (NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv)) {
// create the file on the file system.
rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 0644); // XXX what permissions???
if (NS_ERROR_FILE_ALREADY_EXISTS == rv) {
rv = file->Delete(PR_FALSE); // the user has already confirmed they
// want to overwrite the file.
if (NS_FAILED(rv)) {
this->OnError(kOpCreateFile, rv);
return rv;
}
rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 0644); // XXX what permissions???
if (NS_FAILED(rv)) {
this->OnError(kOpCreateFile, rv);
return rv;
}
} else if (NS_FAILED(rv)) {
this->OnError(kOpCreateFile, rv);
return rv;
}
rv = fts->CreateTransport(file, PR_RDONLY, "load", 0, 0,
getter_AddRefs( mOutputChannel));
}
if ( NS_SUCCEEDED( rv ) ) {
// reset the channel's interface requestor so we receive status