diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-28 19:19:29 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-28 19:19:29 +0000 |
commit | ba2c74103a8d751bfcde61cff2fc8e198d860400 (patch) | |
tree | 54abf20b687a500e19f3abaeebc431d2e2a1ad3c | |
parent | ad3b0ff4049f97d6d20a5a8ca8115ef6f269adbf (diff) | |
parent | 40ab64211cc89ec112e5baf8c7ff78ad4680b7a3 (diff) |
koheidatapilot03: merge with DEV300_m63
-rw-r--r-- | idlc/inc/idlc/options.hxx | 4 | ||||
-rw-r--r-- | idlc/source/idlcmain.cxx | 31 | ||||
-rw-r--r-- | idlc/source/options.cxx | 18 | ||||
-rw-r--r-- | offapi/util/makefile.mk | 12 | ||||
-rw-r--r-- | offapi/util/target.pmk | 4 | ||||
-rw-r--r-- | registry/source/keyimpl.cxx | 4 | ||||
-rw-r--r-- | registry/source/regimpl.cxx | 5 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 142 | ||||
-rw-r--r-- | sal/osl/w32/file.cxx | 76 | ||||
-rw-r--r-- | stoc/prj/build.lst | 2 | ||||
-rw-r--r-- | udkapi/util/target.pmk | 4 |
11 files changed, 210 insertions, 92 deletions
diff --git a/idlc/inc/idlc/options.hxx b/idlc/inc/idlc/options.hxx index e55dc961903b..11bc0fe4d657 100644 --- a/idlc/inc/idlc/options.hxx +++ b/idlc/inc/idlc/options.hxx @@ -69,11 +69,15 @@ public: const StringVector& getInputFiles() const { return m_inputFiles; } bool readStdin() const { return m_stdin; } + bool verbose() const { return m_verbose; } + bool quiet() const { return m_quiet; } protected: ::rtl::OString m_program; StringVector m_inputFiles; bool m_stdin; + bool m_verbose; + bool m_quiet; OptionMap m_options; }; diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index 1ce3a9fa05b0..68c1ae7cf5a5 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -56,11 +56,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) sal_Int32 nErrors = 0; if (options.readStdin()) { - fprintf( - stdout, "%s: compile stdin...\n", - options.getProgramName().getStr()); + if ( !options.quiet() ) + fprintf( + stdout, "%s: Compiling stdin\n", + options.getProgramName().getStr()); nErrors = compileFile(0); - if (idlc()->getWarningCount() > 0) { + if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) { fprintf( stdout, "%s: detected %lu warnings compiling stdin\n", options.getProgramName().getStr(), @@ -85,16 +86,23 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) idlc()->reset(); } StringVector const & files = options.getInputFiles(); + if ( options.verbose() ) + { + fprintf( stdout, "%s: compiling %i source files ... \n", + options.getProgramName().getStr(), (int)files.size() ); + fflush( stdout ); + } for (StringVector::const_iterator i(files.begin()); i != files.end() && nErrors == 0; ++i) { OString sysFileName( convertToAbsoluteSystemPath(*i) ); - fprintf(stdout, "%s: compile '%s' ... \n", - options.getProgramName().getStr(), (*i).getStr()); + if ( !options.quiet() ) + fprintf(stdout, "Compiling: %s\n", + (*i).getStr()); nErrors = compileFile(&sysFileName); - if ( idlc()->getWarningCount() ) + if ( idlc()->getWarningCount() && !options.quiet() ) fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n", options.getProgramName().getStr(), sal::static_int_cast< unsigned long >( @@ -128,15 +136,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) if ( nErrors > 0 ) { - fprintf(stdout, "%s: detected %ld errors%s", + fprintf(stderr, "%s: detected %ld errors%s", options.getProgramName().getStr(), sal::static_int_cast< long >(nErrors), options.prepareVersion().getStr()); } else { - fprintf(stdout, "%s: returned successful%s", - options.getProgramName().getStr(), - options.prepareVersion().getStr()); + if ( options.verbose() ) + fprintf(stdout, "%s: returned successful%s", + options.getProgramName().getStr(), + options.prepareVersion().getStr()); } return nErrors; } diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index 6bfbcc9e443e..963ddafda8d0 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -37,7 +37,7 @@ using namespace rtl; -Options::Options(): m_stdin(false) +Options::Options(): m_stdin(false), m_verbose(false), m_quiet(false) { } @@ -190,6 +190,22 @@ sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile) } else throw IllegalArgument(OString(av[j]) + ", please check your input"); break; + case 'v': + if ( 0 == strcmp( &av[j][1], "verbose" ) ) + { + m_verbose = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; + case 'q': + if ( 0 == strcmp( &av[j][1], "quiet" ) ) + { + m_quiet = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; case 'w': if (av[j][2] == 'e' && av[j][3] == '\0') { if (m_options.count("-we") == 0) diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk index b0fa7a30cf46..d3157dac31df 100644 --- a/offapi/util/makefile.mk +++ b/offapi/util/makefile.mk @@ -164,14 +164,14 @@ ALLTAR : $(UCR)$/types.db \ $(UNOTYPE_STATISTICS) $(UCR)$/types.db : $(UCR)$/offapi.db $(SOLARBINDIR)$/udkapi.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(UCR)$/offapi.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(UCR)$/offapi.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb $(OUT)$/ucrdoc$/types_doc.db : $(OUT)$/ucrdoc$/offapi_doc.db $(SOLARBINDIR)$/udkapi_doc.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb #JSC: The type library has changed, all temporary not checked types are removed # and will be check from now on. diff --git a/offapi/util/target.pmk b/offapi/util/target.pmk index 08912b011857..63804f3e554a 100644 --- a/offapi/util/target.pmk +++ b/offapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls 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..8e7d76cda614 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -44,6 +44,7 @@ #include <limits> #include <string.h> +#include <pthread.h> #include <sys/mman.h> #if defined(MACOSX) @@ -74,8 +75,9 @@ ******************************************************************/ struct FileHandle_Impl { - rtl_String * m_strFilePath; /* holds native file path */ - int m_fd; + pthread_mutex_t m_mutex; + rtl_String * m_strFilePath; /* holds native file path */ + int m_fd; /** State */ @@ -110,6 +112,7 @@ struct FileHandle_Impl oslFileError setPos (sal_uInt64 uPos); sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uSize); oslFileError readAt ( off_t nOffset, @@ -168,6 +171,17 @@ struct FileHandle_Impl Allocator(); ~Allocator(); }; + + /** Guard. + */ + class Guard + { + pthread_mutex_t * m_mutex; + + public: + explicit Guard(pthread_mutex_t * pMutex); + ~Guard(); + }; }; /******************************************************************* @@ -212,6 +226,18 @@ void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) rtl_cache_free (m_cache, pBuffer); } +FileHandle_Impl::Guard::Guard(pthread_mutex_t * pMutex) + : m_mutex (pMutex) +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + (void) pthread_mutex_lock (m_mutex); // ignoring EINVAL ... +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + (void) pthread_mutex_unlock (m_mutex); +} + FileHandle_Impl::FileHandle_Impl (int fd, char const * path) : m_strFilePath (0), m_fd (fd), @@ -224,6 +250,7 @@ FileHandle_Impl::FileHandle_Impl (int fd, char const * path) m_bufsiz (0), m_buffer (0) { + (void) pthread_mutex_init(&m_mutex, 0); rtl_string_newFromStr (&m_strFilePath, path); Allocator::get().allocate (&m_buffer, &m_bufsiz); if (0 != m_buffer) @@ -233,6 +260,7 @@ FileHandle_Impl::~FileHandle_Impl() { Allocator::get().deallocate (m_buffer), m_buffer = 0; rtl_string_release (m_strFilePath), m_strFilePath = 0; + (void) pthread_mutex_destroy(&m_mutex); // ignoring EBUSY ... } void* FileHandle_Impl::operator new (size_t n) @@ -271,6 +299,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, @@ -906,6 +975,8 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) if ((pImpl == 0) || (pImpl->m_fd < 0)) return osl_File_E_INVAL; + (void) pthread_mutex_lock (&(pImpl->m_mutex)); + /* close(2) implicitly (and unconditionally) unlocks */ OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath)); oslFileError result = pImpl->syncFile(); @@ -920,6 +991,7 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) result = oslTranslateFileError (OSL_FET_ERROR, errno); } + (void) pthread_mutex_unlock (&(pImpl->m_mutex)); delete pImpl; return (result); } @@ -935,6 +1007,8 @@ SAL_CALL osl_syncFile(oslFileHandle Handle) if ((0 == pImpl) || (-1 == pImpl->m_fd)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + OSL_FILE_TRACE("osl_syncFile(%d)", pImpl->m_fd); oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) @@ -1044,6 +1118,7 @@ SAL_CALL osl_readLine ( sal_uInt64 uBytesRead = 0; // read at current fileptr; fileptr += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readLineAt ( pImpl->m_fileptr, ppSequence, &uBytesRead); if (result == osl_File_E_None) @@ -1072,6 +1147,7 @@ SAL_CALL osl_readFile ( size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); // read at current fileptr; fileptr += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readFileAt ( pImpl->m_fileptr, pBuffer, nBytesRequested, pBytesRead); if (result == osl_File_E_None) @@ -1102,6 +1178,7 @@ SAL_CALL osl_writeFile ( size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); // write at current fileptr; fileptr += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->writeFileAt ( pImpl->m_fileptr, pBuffer, nBytesToWrite, pBytesWritten); if (result == osl_File_E_None) @@ -1138,6 +1215,7 @@ SAL_CALL osl_readFileAt ( size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->readFileAt (nOffset, pBuffer, nBytesRequested, pBytesRead); } @@ -1172,6 +1250,7 @@ SAL_CALL osl_writeFileAt ( size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->writeFileAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten); } @@ -1186,6 +1265,7 @@ SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pIsEOF)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pIsEOF = (pImpl->getPos() == pImpl->getSize()); return osl_File_E_None; } @@ -1201,6 +1281,7 @@ SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pPos)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pPos = pImpl->getPos(); return osl_File_E_None; } @@ -1221,6 +1302,7 @@ SAL_CALL osl_setFilePos (oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffse return osl_File_E_OVERFLOW; off_t nPos = 0, nOffset = sal::static_int_cast< off_t >(uOffset); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); switch(uHow) { case osl_Pos_Absolut: @@ -1262,6 +1344,7 @@ SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize ) if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pSize)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pSize = pImpl->getSize(); return osl_File_E_None; } @@ -1282,62 +1365,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..34deba2293da 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -69,7 +69,8 @@ //################################################################## struct FileHandle_Impl { - HANDLE m_hFile; + CRITICAL_SECTION m_mutex; + HANDLE m_hFile; /** State */ @@ -103,6 +104,7 @@ struct FileHandle_Impl oslFileError setPos (sal_uInt64 uPos); sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uPos); oslFileError readAt ( LONGLONG nOffset, @@ -161,6 +163,17 @@ struct FileHandle_Impl Allocator(); ~Allocator(); }; + + /** Guard. + */ + class Guard + { + LPCRITICAL_SECTION m_mutex; + + public: + explicit Guard(LPCRITICAL_SECTION pMutex); + ~Guard(); + }; }; FileHandle_Impl::Allocator & @@ -198,6 +211,18 @@ void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) rtl_cache_free (m_cache, pBuffer); } +FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex) + : m_mutex (pMutex) +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + ::EnterCriticalSection (m_mutex); +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + ::LeaveCriticalSection (m_mutex); +} + FileHandle_Impl::FileHandle_Impl(HANDLE hFile) : m_hFile (hFile), m_state (STATE_READABLE | STATE_WRITEABLE), @@ -209,6 +234,7 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile) m_bufsiz (0), m_buffer (0) { + ::InitializeCriticalSection (&m_mutex); Allocator::get().allocate (&m_buffer, &m_bufsiz); if (m_buffer != 0) memset (m_buffer, 0, m_bufsiz); @@ -217,6 +243,7 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile) FileHandle_Impl::~FileHandle_Impl() { Allocator::get().deallocate (m_buffer), m_buffer = 0; + ::DeleteCriticalSection (&m_mutex); } void * FileHandle_Impl::operator new(size_t n) @@ -253,6 +280,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, @@ -711,6 +755,8 @@ SAL_CALL osl_syncFile(oslFileHandle Handle) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) return result; @@ -729,6 +775,8 @@ SAL_CALL osl_closeFile(oslFileHandle Handle) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; + ::EnterCriticalSection (&(pImpl->m_mutex)); + oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) { @@ -741,6 +789,7 @@ SAL_CALL osl_closeFile(oslFileHandle Handle) result = oslTranslateFileError( GetLastError() ); } + ::LeaveCriticalSection (&(pImpl->m_mutex)); delete pImpl; return (result); } @@ -852,6 +901,7 @@ SAL_CALL osl_readLine( sal_uInt64 uBytesRead = 0; // read at current filepos; filepos += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readLineAt ( pImpl->m_filepos, ppSequence, &uBytesRead); if (result == osl_File_E_None) @@ -872,6 +922,7 @@ SAL_CALL osl_readFile( return osl_File_E_INVAL; // read at current filepos; filepos += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->readFileAt ( pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead); if (result == osl_File_E_None) @@ -893,6 +944,7 @@ SAL_CALL osl_writeFile( return osl_File_E_INVAL; // write at current filepos; filepos += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); oslFileError result = pImpl->writeFileAt ( pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten); if (result == osl_File_E_None) @@ -922,6 +974,7 @@ SAL_CALL osl_readFileAt( LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->readFileAt (nOffset, pBuffer, uBytesRequested, pBytesRead); } @@ -947,6 +1000,7 @@ SAL_CALL osl_writeFileAt( LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); return pImpl->writeFileAt (nOffset, pBuffer, uBytesToWrite, pBytesWritten); } @@ -959,6 +1013,7 @@ SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pIsEOF = (pImpl->getPos() == pImpl->getSize()); return osl_File_E_None; } @@ -971,6 +1026,7 @@ SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pPos = pImpl->getPos(); return osl_File_E_None; } @@ -988,6 +1044,7 @@ SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset return osl_File_E_OVERFLOW; LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); switch (uHow) { case osl_Pos_Absolut: @@ -1027,6 +1084,7 @@ SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize) if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize)) return osl_File_E_INVAL; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); *pSize = pImpl->getSize(); return osl_File_E_None; } @@ -1046,23 +1104,13 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) if (g_limit_longlong < uSize) return osl_File_E_OVERFLOW; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); 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 diff --git a/udkapi/util/target.pmk b/udkapi/util/target.pmk index f6e7bc9beb3c..2a01738e7eb7 100644 --- a/udkapi/util/target.pmk +++ b/udkapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls |