You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2011/12/16 10:07:50 UTC

svn commit: r1215064 - in /incubator/ooo/trunk/main/desktop/source/deployment: dp_persmap.cxx inc/dp_persmap.h

Author: hdu
Date: Fri Dec 16 09:07:50 2011
New Revision: 1215064

URL: http://svn.apache.org/viewvc?rev=1215064&view=rev
Log:
minor cleanups in dp_persmap.*

Modified:
    incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx
    incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_persmap.h

Modified: incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx?rev=1215064&r1=1215063&r2=1215064&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx Fri Dec 16 09:07:50 2011
@@ -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 &
 	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;
 }
 
 //______________________________________________________________________________

Modified: incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_persmap.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_persmap.h?rev=1215064&r1=1215063&r2=1215064&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_persmap.h (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_persmap.h Fri Dec 16 09:07:50 2011
@@ -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);
 };