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
parent 19afa18999
commit ebef130835
2 changed files with 24 additions and 1 deletions

View File

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

View File

@ -164,9 +164,31 @@ nsStreamXferOp::Start( void ) {
mOutputSpec->GetFileSpec( &target ); mOutputSpec->GetFileSpec( &target );
nsCOMPtr<nsILocalFile> file; nsCOMPtr<nsILocalFile> file;
rv = NS_NewLocalFile(target, getter_AddRefs(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, rv = fts->CreateTransport(file, PR_RDONLY, "load", 0, 0,
getter_AddRefs( mOutputChannel)); getter_AddRefs( mOutputChannel));
}
if ( NS_SUCCEEDED( rv ) ) { if ( NS_SUCCEEDED( rv ) ) {
// reset the channel's interface requestor so we receive status // reset the channel's interface requestor so we receive status