Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > cd8ce32c919af60229fca1d7f792c60e > files > 67

openoffice.org-3.2.0-12.35.fc13.src.rpm

diff -ru sal.orig/osl/unx/file_misc.cxx sal/osl/unx/file_misc.cxx
--- sal.orig/osl/unx/file_misc.cxx	2010-08-09 09:13:30.000000000 +0100
+++ sal/osl/unx/file_misc.cxx	2010-08-09 09:21:21.000000000 +0100
@@ -1022,66 +1022,29 @@
         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[0x7FFF];
         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;
-
-                size_t nToRead = std::min( (size_t)32000, 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 );
+            nRead = 0;
+            nWritten = 0;
+
+            size_t nToRead = std::min( sizeof(pBuffer), 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 ( nRemains )