diff options
-rw-r--r-- | registry/source/keyimpl.cxx | 4 | ||||
-rw-r--r-- | registry/source/regimpl.cxx | 5 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 97 | ||||
-rw-r--r-- | sal/osl/w32/file.cxx | 33 | ||||
-rw-r--r-- | stoc/prj/build.lst | 2 |
5 files changed, 74 insertions, 67 deletions
diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx index f8de7e20b148..281c8e27cbf0 100644 --- a/registry/source/keyimpl.cxx +++ b/registry/source/keyimpl.cxx @@ -365,6 +365,7 @@ RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegVal return REG_SET_VALUE_FAILED; } + rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -423,6 +424,7 @@ RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueL return REG_SET_VALUE_FAILED; } + rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -490,6 +492,7 @@ RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValu return REG_SET_VALUE_FAILED; } + rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -557,6 +560,7 @@ RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** p return REG_SET_VALUE_FAILED; } + rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 86165b42bd1d..8a4dd8b88ee9 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -550,6 +550,7 @@ RegError ORegistry::closeRegistry() if (m_file.isValid()) { closeKey(m_openKeyTable[ROOT]); + m_file.flush(); m_file.close(); m_isOpen = sal_False; return REG_NO_ERROR; @@ -847,6 +848,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName) { return REG_DELETE_KEY_FAILED; } + sFile.flush(); // set flag deleted !!! ((ORegKey*)hOldKey)->setDeleted(sal_True); @@ -892,6 +894,7 @@ RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey) { return REG_DELETE_VALUE_FAILED; } + ((OStoreFile&)pKey->getStoreFile()).flush(); } _err = rStoreDir.next(iter); @@ -1062,6 +1065,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey, { return REG_VALUE_NOT_EXISTS; } + pSourceKey->getStoreFile().flush(); pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); @@ -1133,6 +1137,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey, rtl_freeMemory(pBuffer); return REG_INVALID_VALUE; } + rTargetFile.flush(); if (rwBytes != nSize) { diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index c8ebf5ad11c5..b69849a08cdc 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -110,6 +110,7 @@ struct FileHandle_Impl oslFileError setPos (sal_uInt64 uPos); sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uSize); oslFileError readAt ( off_t nOffset, @@ -271,6 +272,47 @@ sal_uInt64 FileHandle_Impl::getSize() const return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); } +oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) +{ + off_t const nSize = sal::static_int_cast< off_t >(uSize); + if (-1 == ftruncate (m_fd, nSize)) + { + /* Failure. Save original result. Try fallback algorithm */ + oslFileError result = oslTranslateFileError (OSL_FET_ERROR, errno); + + /* Check against current size. Fail upon 'shrink' */ + if (uSize <= getSize()) + { + /* Failure upon 'shrink'. Return original result */ + return (result); + } + + /* Save current position */ + off_t const nCurPos = (off_t)lseek (m_fd, (off_t)0, SEEK_CUR); + if (nCurPos == (off_t)(-1)) + return (result); + + /* Try 'expand' via 'lseek()' and 'write()' */ + if (-1 == lseek (m_fd, (off_t)(nSize - 1), SEEK_SET)) + return (result); + + if (-1 == write (m_fd, (char*)"", (size_t)1)) + { + /* Failure. Restore saved position */ + (void) lseek (m_fd, (off_t)(nCurPos), SEEK_SET); + return (result); + } + + /* Success. Restore saved position */ + if (-1 == lseek (m_fd, (off_t)nCurPos, SEEK_SET)) + return (result); + } + + OSL_FILE_TRACE("osl_setFileSize(%d, %lld) => %ld", m_fd, getSize(), nSize); + m_size = sal::static_int_cast< sal_uInt64 >(nSize); + return osl_File_E_None; +} + oslFileError FileHandle_Impl::readAt ( off_t nOffset, void * pBuffer, @@ -1282,62 +1324,11 @@ SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize ) static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max(); if (g_limit_off_t < uSize) return osl_File_E_OVERFLOW; - off_t const nSize = sal::static_int_cast< off_t >(uSize); oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return (result); + pImpl->m_bufptr = -1, pImpl->m_buflen = 0; - if (-1 == ftruncate (pImpl->m_fd, nSize)) - { - /* Failure. Try fallback algorithm */ - off_t nCurPos; - - /* Save original result */ - result = oslTranslateFileError (OSL_FET_ERROR, errno); - PERROR("ftruncate", "Try osl_setFileSize [fallback]\n"); - - /* Check against current size. Fail upon 'shrink' */ - if (uSize <= pImpl->getSize()) - { - /* Failure upon 'shrink'. Return original result */ - return (result); - } - - /* Save current position *//* @@@ pImpl->m_offset @@@ */ - nCurPos = (off_t)lseek (pImpl->m_fd, (off_t)0, SEEK_CUR); - if (nCurPos == (off_t)(-1)) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n"); - return (result); - } - - /* Try 'expand' via 'lseek()' and 'write()' */ - if (lseek (pImpl->m_fd, (off_t)(nSize - 1), SEEK_SET) < 0) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n"); - return (result); - } - if (write (pImpl->m_fd, (char*)"", (size_t)1) < 0) - { - /* Failure. Restore saved position */ - PERROR("ftruncate: write", "Out osl_setFileSize [error]\n"); - if (lseek (pImpl->m_fd, (off_t)nCurPos, SEEK_SET) < 0) - { - PERROR("ftruncate: lseek", "ignoring"); - } - return (result); - } - - /* Success. Restore saved position */ - if (lseek (pImpl->m_fd, (off_t)nCurPos, SEEK_SET) < 0) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]"); - return (result); - } - } - - OSL_FILE_TRACE("osl_setFileSize(%d, %lld) => %ld", pImpl->m_fd, pImpl->getSize(), nSize); - pImpl->m_size = sal::static_int_cast< sal_uInt64 >(nSize); - return osl_File_E_None; + return pImpl->setSize (uSize); } diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index b6a7c64ee873..d2eb9e7a4523 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -103,6 +103,7 @@ struct FileHandle_Impl oslFileError setPos (sal_uInt64 uPos); sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uPos); oslFileError readAt ( LONGLONG nOffset, @@ -253,6 +254,23 @@ sal_uInt64 FileHandle_Impl::getSize() const return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); } +oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) +{ + LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize); + if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); + + if (!::SetEndOfFile(m_hFile)) + return oslTranslateFileError( GetLastError() ); + m_size = uSize; + + nDstPos.QuadPart = m_offset; + if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); + + return osl_File_E_None; +} + oslFileError FileHandle_Impl::readAt ( LONGLONG nOffset, void * pBuffer, @@ -1049,20 +1067,9 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return (result); + pImpl->m_bufptr = -1, pImpl->m_buflen = 0; - LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize); - if (!::SetFilePointerEx(pImpl->m_hFile, nDstPos, 0, FILE_BEGIN)) - return oslTranslateFileError( GetLastError() ); - - if (!::SetEndOfFile(pImpl->m_hFile)) - return oslTranslateFileError( GetLastError() ); - pImpl->m_size = uSize; - - nDstPos.QuadPart = pImpl->m_offset; - if (!::SetFilePointerEx(pImpl->m_hFile, nDstPos, 0, FILE_BEGIN)) - return oslTranslateFileError( GetLastError() ); - - return osl_File_E_None; + return pImpl->setSize (uSize); } //################################################################## diff --git a/stoc/prj/build.lst b/stoc/prj/build.lst index 4748ffcff26f..2550563c8c34 100644 --- a/stoc/prj/build.lst +++ b/stoc/prj/build.lst @@ -21,4 +21,4 @@ tc stoc\source\typeconv nmake - all tc_tcv tc_stserv tc_nservice tc_inc NULL tc stoc\source\javavm nmake - all tc_jvm tc_inc NULL tc stoc\source\javaloader nmake - all tc_jvload tc_inc NULL tc stoc\source\uriproc nmake - all tc_uriproc tc_stserv tc_inc NULL -tc stoc\util nmake - all tc_util tc_boot tc_stserv tc_tcv tc_uriproc tc_smgr tc_inc tc_sreg tc_defr tc_ireg tc_regtd tc_tdmng NULL +tc stoc\util nmake - all tc_util tc_boot tc_stserv tc_tcv tc_uriproc tc_smgr tc_inc tc_sreg tc_defr tc_ireg tc_regtd tc_tdmng tc_sec NULL |