summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/file/shell.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'ucb/source/ucp/file/shell.cxx')
-rwxr-xr-x[-rw-r--r--]ucb/source/ucp/file/shell.cxx38
1 files changed, 19 insertions, 19 deletions
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx
index 6e6f9931ef8e..c4131cab233b 100644..100755
--- a/ucb/source/ucp/file/shell.cxx
+++ b/ucb/source/ucp/file/shell.cxx
@@ -1806,14 +1806,26 @@ shell::write( sal_Int32 CommandId,
{
aFile.close();
err = aFile.open( osl_File_OpenFlag_Write );
- }
- if( err != osl::FileBase::E_None )
- {
- installError( CommandId,
- TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE,
- err );
- return sal_False;
+ if( err != osl::FileBase::E_None )
+ {
+ installError( CommandId,
+ TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE,
+ err );
+ return sal_False;
+ }
+
+ // the existing file was just opened and should be overwritten now,
+ // truncate it first
+
+ err = aFile.setSize( 0 );
+ if( err != osl::FileBase::E_None )
+ {
+ installError( CommandId,
+ TASKHANDLING_FILESIZE_FOR_WRITE,
+ err );
+ return sal_False;
+ }
}
}
else
@@ -1845,7 +1857,6 @@ shell::write( sal_Int32 CommandId,
sal_Bool bSuccess = sal_True;
- sal_uInt64 nTotalNumberOfBytes = 0;
sal_uInt64 nWrittenBytes;
sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/;
uno::Sequence< sal_Int8 > seq( nRequestedBytes );
@@ -1902,20 +1913,9 @@ shell::write( sal_Int32 CommandId,
bSuccess = sal_False;
break;
}
-
- nTotalNumberOfBytes += nWrittenBytes;
}
} while( nReadBytes == nRequestedBytes );
- err = aFile.setSize( nTotalNumberOfBytes );
- if( err != osl::FileBase::E_None )
- {
- installError( CommandId,
- TASKHANDLING_FILESIZE_FOR_WRITE,
- err );
- bSuccess = sal_False;
- }
-
err = aFile.close();
if( err != osl::FileBase::E_None )
{