27#include <rtl/byteseq.hxx>
28#include <rtl/strbuf.hxx>
48, m_bToBeCreated( true )
55: m_MapFile( OUString() )
57, m_bToBeCreated( false )
74 const char*
pChar = rStr.getStr();
75 const sal_Int32 nLen = rStr.getLength();
80 const unsigned char c =
static_cast<unsigned char>(*(
pChar++));
90 OStringBuffer aEncStr( nLen + 32);
91 aEncStr.append(
pChar - (nLen-
i), nLen -
i);
94 unsigned char c =
static_cast<unsigned char>(*(
pChar++));
98 c += (c <= 0x09) ?
'0' :
'A'-10;
100 aEncStr.append(
'%');
101 aEncStr.append(
char(c) );
104 return aEncStr.makeStringAndClear();
111 const char*
pChar = pEncChars;
115 if( *(
pChar++) ==
'%')
118 return OString( pEncChars, nLen);
121 OStringBuffer aDecStr( nLen);
123 for(
i = nLen; --
i >= 0;)
132 if( (
'0' <= c) && (c <=
'9'))
136 OSL_ASSERT( (
'A' <= c) && (c <=
'F'));
143 return aDecStr.makeStringAndClear();
149 sal_uInt32
const nOpenFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write;
151 const osl::File::RC rcOpen =
m_MapFile.open( nOpenFlags);
152 m_bIsOpen = (rcOpen == osl::File::E_None);
168 const osl::FileBase::RC nRes =
m_MapFile.setPos( osl_Pos_Absolut, 0);
169 if (nRes != osl::FileBase::E_None)
171 SAL_WARN(
"desktop.deployment",
"setPos failed with " << +nRes);
177 sal_uInt64 nBytesRead = 0;
178 m_MapFile.read( aHeaderBytes,
sizeof(aHeaderBytes), nBytesRead);
179 OSL_ASSERT( nBytesRead ==
sizeof(aHeaderBytes));
180 if( nBytesRead !=
sizeof(aHeaderBytes))
188 ByteSequence aKeyLine;
189 ByteSequence aValLine;
194 if(
m_MapFile.readLine( aKeyLine) != osl::File::E_None)
196 if( !aKeyLine.getLength())
198 if(
m_MapFile.readLine( aValLine) != osl::File::E_None)
201 const OString aKeyName =
decodeString(
reinterpret_cast<char const *
>(aKeyLine.getConstArray()), aKeyLine.getLength());
202 const OString aValName =
decodeString(
reinterpret_cast<char const *
>(aValLine.getConstArray()), aValLine.getLength());
204 add( aKeyName, aValName );
207 if(
m_MapFile.isEndOfFile( &bIsEOF) != osl::File::E_None )
222 const sal_uInt32 nOpenFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create;
223 const osl::File::RC rcOpen =
m_MapFile.open( nOpenFlags);
224 m_bIsOpen = (rcOpen == osl::File::E_None);
231 const osl::FileBase::RC nRes =
m_MapFile.setPos( osl_Pos_Absolut, 0);
232 if (nRes != osl::FileBase::E_None)
234 SAL_WARN(
"desktop.deployment",
"setPos failed with " << +nRes);
237 sal_uInt64 nBytesWritten = 0;
245 const sal_Int32 nKeyLen = aKeyString.getLength();
246 m_MapFile.write( aKeyString.getStr(), nKeyLen, nBytesWritten);
248 m_MapFile.write(
"\n", 1, nBytesWritten);
250 const OString& rValString =
encodeString( entry.second);
251 const sal_Int32 nValLen = rValString.getLength();
252 m_MapFile.write( rValString.getStr(), nValLen, nBytesWritten);
254 m_MapFile.write(
"\n", 1, nBytesWritten);
258 m_MapFile.write(
"\n", 1, nBytesWritten);
260 sal_uInt64 nNewFileSize;
261 if(
m_MapFile.getPos( nNewFileSize) == osl::File::E_None)
271 return get(
nullptr, key );
276 t_string2string_map::const_iterator it =
m_entries.find( key);
bool get(OString *value, OString const &key) const
void put(OString const &key, OString const &value)
bool has(OString const &key) const
bool erase(OString const &key)
void add(OString const &key, OString const &value)
t_string2string_map m_entries
#define SAL_WARN(area, stream)
static OString encodeString(const OString &rStr)
OUString expandUnoRcUrl(OUString const &url)
static OString decodeString(const char *pEncChars, int nLen)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)