21#include <com/sun/star/io/IOException.hpp>
23#include <rtl/byteseq.hxx>
30 if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
34 oslFileHandle handle=
nullptr;
35 oslFileError fileError = osl_File_E_INVAL;
37 if (!iniUrl.isEmpty())
38 fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
40 catch(
const css::io::IOException&)
42 SAL_WARN(
"connectivity.mozab",
"couldn't open file: " << iniUrl );
45 if (osl_File_E_None == fileError)
47 rtl::ByteSequence seq;
50 osl_getFileSize(handle, &nSize);
51 OUString sectionName(
"no name section" );
55 if (osl_File_E_None != osl_getFilePos(handle, &
nPos) ||
nPos >= nSize)
57 if (osl_File_E_None != osl_readLine(handle,
reinterpret_cast<sal_Sequence **
>(&seq)))
59 OString
line(
reinterpret_cast<const char *
>(seq.getConstArray()), seq.getLength() );
65 nameValue.
sName = OStringToOUString(
67 nameValue.
sValue = OStringToOUString(
70 aSection->
vVector.push_back(nameValue);
75 sal_Int32 nIndexStart =
line.indexOf(
'[');
76 sal_Int32 nIndexEnd =
line.indexOf(
']');
77 if ( nIndexEnd > nIndexStart && nIndexStart >=0)
79 sectionName = OStringToOUString(
80 o3tl::trim(
line.subView(nIndexStart + 1,nIndexEnd - nIndexStart -1)), RTL_TEXTENCODING_ASCII_US );
81 if (sectionName.isEmpty())
82 sectionName =
"no name section";
86 osl_closeFile(handle);
90 SAL_INFO(
"connectivity.mozab",
"couldn't open file: " << iniUrl );
IniSectionMap mAllSection
IniParser(OUString const &rIniName)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)