summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-11-09 15:38:59 +0100
committerVladimir Glazunov <vg@openoffice.org>2010-11-09 15:38:59 +0100
commitaa35318f6af7d583a6d39dc8483fccc5b413ac2c (patch)
tree4d3ff88352623f10c6b6611555a6127a859431cc /sal
parentcb63b636df2120365da2a8efb9cf75310cb898fa (diff)
parentda79c9ea6dc7e590f39836904907341b69fc24e5 (diff)
CWS-TOOLING: integrate CWS fwk149
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_misc.cxx57
1 files changed, 11 insertions, 46 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 331b91cb1626..452d3eb2db70 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -1022,66 +1022,31 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD
return nRet;
}
- /* HACK: because memory mapping fails on various
- platforms if the size of the source file is 0 byte */
- if (0 == nSourceSize)
- {
- close(SourceFileFD);
- close(DestFileFD);
- return 0;
- }
-
- // read and lseek are used to check the possibility to access the data
- // not a nice solution, but it allows to avoid a crash in case it is an opened samba file
- // generally, reading of one byte should not affect the performance
- char nCh;
- if ( 1 != read( SourceFileFD, &nCh, 1 )
- || -1 == lseek( SourceFileFD, 0, SEEK_SET ) )
- {
- nRet = errno;
- close( SourceFileFD );
- close( DestFileFD );
- return nRet;
- }
-
size_t nWritten = 0;
size_t nRemains = nSourceSize;
- /* mmap file -- open dest file -- write -- fsync it at the end */
- void* pSourceFile = mmap( 0, nSourceSize, PROT_READ, MAP_SHARED, SourceFileFD, 0 );
- if ( pSourceFile != MAP_FAILED )
- {
- nWritten = write( DestFileFD, pSourceFile, nSourceSize );
- nRemains -= nWritten;
- munmap( (char*)pSourceFile, nSourceSize );
- }
-
if ( nRemains )
{
/* mmap has problems, try the direct streaming */
- char pBuffer[32000];
+ char pBuffer[0x8000];
size_t nRead = 0;
nRemains = nSourceSize;
- if ( -1 != lseek( SourceFileFD, 0, SEEK_SET )
- && -1 != lseek( DestFileFD, 0, SEEK_SET ) )
+ do
{
- do
- {
- nRead = 0;
- nWritten = 0;
+ nRead = 0;
+ nWritten = 0;
- size_t nToRead = std::min( (size_t)32000, nRemains );
- nRead = read( SourceFileFD, pBuffer, nToRead );
- if ( (size_t)-1 != nRead )
- nWritten = write( DestFileFD, pBuffer, nRead );
+ size_t nToRead = std::min( (size_t)0x8000, nRemains );
+ nRead = read( SourceFileFD, pBuffer, nToRead );
+ if ( (size_t)-1 != nRead )
+ nWritten = write( DestFileFD, pBuffer, nRead );
- if ( (size_t)-1 != nWritten )
- nRemains -= nWritten;
- }
- while( nRemains && (size_t)-1 != nRead && nRead == nWritten );
+ if ( (size_t)-1 != nWritten )
+ nRemains -= nWritten;
}
+ while( nRemains && (size_t)-1 != nRead && nRead == nWritten );
}
if ( nRemains )