diff options
author | Herbert Dürr <hdu@apache.org> | 2011-12-16 08:07:50 +0000 |
---|---|---|
committer | Herbert Dürr <hdu@apache.org> | 2011-12-16 08:07:50 +0000 |
commit | 54de47df2adf9cac89cd315a2b340c858339c830 (patch) | |
tree | f50eafd77326af9e68e987971016341ac5e93969 | |
parent | af644e3b54a1ce1ceb659dda8024d7db19ba40e6 (diff) |
minor cleanups in dp_persmap.*
-rw-r--r-- | desktop/source/deployment/dp_persmap.cxx | 23 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_persmap.h | 5 |
2 files changed, 19 insertions, 9 deletions
diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx index a6560245a792..ec03e0061aed 100644 --- a/desktop/source/deployment/dp_persmap.cxx +++ b/desktop/source/deployment/dp_persmap.cxx @@ -32,8 +32,8 @@ using namespace ::rtl; // this implementation replaces a rather heavy-weight berkeleydb integration // the file backing up a persistent map consists of line pairs with -// - an encoded key name (with chars 0x00..0x0F being escaped) -// - an encoded value name (with chars 0x00..0x0F being escaped) +// - a key string (encoded with chars 0x00..0x0F being escaped) +// - a value string (encoded with chars 0x00..0x0F being escaped) namespace dp_misc { @@ -157,14 +157,25 @@ bool PersistentMap::open() if( !m_bReadOnly) nOpenFlags |= osl_File_OpenFlag_Write; - ::osl::File::RC rcOpen = m_MapFile.open( nOpenFlags); + const ::osl::File::RC rcOpen = m_MapFile.open( nOpenFlags); m_bIsOpen = (rcOpen == osl::File::E_None); // or create later if needed - m_bToBeCreated = (rcOpen == osl::File::E_NOENT) && !m_bIsOpen; + m_bToBeCreated &= (rcOpen == osl::File::E_NOENT) && !m_bIsOpen; if( !m_bIsOpen) return m_bToBeCreated; + const bool readOK = readAll(); + return readOK; +} + +//______________________________________________________________________________ +bool PersistentMap::readAll() +{ + // prepare for re-reading the map-file + m_MapFile.setPos( osl_Pos_Absolut, 0); + m_entries.clear(); + // read header and check magic char aHeaderBytes[ sizeof(PmapMagic)]; sal_uInt64 nBytesRead = 0; @@ -203,6 +214,7 @@ bool PersistentMap::open() break; } + m_bIsDirty = false; return true; } @@ -215,7 +227,7 @@ void PersistentMap::flush( void) if( m_bToBeCreated && !m_entries.empty()) { const sal_uInt32 nOpenFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create; - ::osl::File::RC rcOpen = m_MapFile.open( nOpenFlags); + const ::osl::File::RC rcOpen = m_MapFile.open( nOpenFlags); m_bIsOpen = (rcOpen == osl::File::E_None); m_bToBeCreated = !m_bIsOpen; } @@ -281,7 +293,6 @@ void PersistentMap::put( OString const & key, OString const & value ) typedef std::pair<t_string2string_map::iterator,bool> InsertRC; InsertRC r = m_entries.insert( t_string2string_map::value_type(key,value)); m_bIsDirty = r.second; - (void)r; } //______________________________________________________________________________ diff --git a/desktop/source/deployment/inc/dp_persmap.h b/desktop/source/deployment/inc/dp_persmap.h index a68068732487..4f0398c3c841 100644 --- a/desktop/source/deployment/inc/dp_persmap.h +++ b/desktop/source/deployment/inc/dp_persmap.h @@ -19,8 +19,6 @@ * *************************************************************/ - - #if ! defined INCLUDED_DP_PERSMAP_H #define INCLUDED_DP_PERSMAP_H @@ -56,8 +54,9 @@ public: void put( ::rtl::OString const & key, ::rtl::OString const & value ); bool erase( ::rtl::OString const & key, bool flush_immediately = true ); -private: +protected: bool open( void); + bool readAll( void); void flush( void); }; |