summaryrefslogtreecommitdiff
path: root/sal/osl/unx/file_misc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sal/osl/unx/file_misc.cxx')
-rw-r--r--sal/osl/unx/file_misc.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 0bde1616f6ae..7d797c2be226 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -1013,6 +1013,15 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD
return nRet;
}
+ DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode);
+
+ if ( DestFileFD < 0 )
+ {
+ nRet=errno;
+ close(SourceFileFD);
+ return nRet;
+ }
+
/* HACK: because memory mapping fails on various
platforms if the size of the source file is 0 byte */
if (0 == nSourceSize)
@@ -1030,16 +1039,8 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD
|| -1 == lseek( SourceFileFD, 0, SEEK_SET ) )
{
nRet = errno;
- (void) close( SourceFileFD );
- return nRet;
- }
-
- DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode);
-
- if ( DestFileFD < 0 )
- {
- nRet=errno;
- close(SourceFileFD);
+ close( SourceFileFD );
+ close( DestFileFD );
return nRet;
}