#include <unistd.h>
#include <new>
#include <unique_ptr.h>
+#include <string.h>
+#include <errno.h>
#include <FBaseInteger.h>
#include <FBaseDouble.h>
#include <FBase_StringConverter.h>
#include <FBase_LocalizedNumParser.h>
+#include <FBase_NativeError.h>
#include <FApp_AppInfo.h>
#include "FIo_FileImpl.h"
#include "FIo_NormalRegistry.h"
}
r = _RegistryCore::AddSection(_sectionList, sectionName);
- SysTryCatch(NID_IO, !IsFailed(r), , r, "[%s] Propagated.", GetErrorMessage(r));
+ SysTryCatch(NID_IO, !IsFailed(r) || r == E_SECTION_ALREADY_EXIST, , r, "[%s] Propagating to caller...", GetErrorMessage(r));
}
else // not a section.. but may belongs to a section (entry)
{
"[E_PARSING_FAILED] Entry name could not be parsed.");
}
- line.SubString(firstTokenPos + 1, entryVal); // extract entry value
+ if (line.GetLength() > firstTokenPos + 1)
+ {
+ line.SubString(firstTokenPos + 1, entryVal); // extract entry value
+ }
// check if entry value contains invalid chars
pEntryValue.reset(_StringConverter::CopyToCharArrayN(entryVal));
if (sectionFound == true)
{
+ SysLog(NID_IO, "[E_SECTION_ALREADY_EXIST] The registry file has the duplicated section name.");
return E_SECTION_ALREADY_EXIST;
}
if (_sectionList.GetCount() == 0)
{
unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(_regPath));
- truncate(pFilePath.get(), 0);
-
+ int res = truncate(pFilePath.get(), 0);
+ SysTryReturnResult(NID_IO, res == 0, __ConvertNativeErrorToResult(errno),
+ "Failed to truncate. errno: %d (%s)", errno, strerror(errno));
return E_SUCCESS;
}
if (sectionFound == true)
{
+ SysLog(NID_IO, "[E_SECTION_ALREADY_EXIST] The registry file has the duplicated section name.");
return E_SECTION_ALREADY_EXIST;
}