r = reg.Construct(__regPath, "a+");
SysAssertf(!IsFailed(r), "[%s] Constructing the registry file (%ls) has failed.", GetErrorMessage(r), __regPath.GetPointer());
+ FileLock* pReglock = reg.LockN(FILE_LOCK_EXCLUSIVE);
+ SysTryLog(NID_APP, pReglock != null, "[%s] Locking the app registry file has failed.", GetErrorMessage(GetLastResult()));
+
r = reg.AddSection(__sectionName);
if (r == E_SECTION_ALREADY_EXIST)
{
r = E_SUCCESS;
}
+
+ delete pReglock;
}
return r;
}
}
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)
{
if (sectionFound == true)
{
+ SysLog(NID_IO, "[E_SECTION_ALREADY_EXIST] The registry file has the duplicated section name.");
return E_SECTION_ALREADY_EXIST;
}
if (sectionFound == true)
{
+ SysLog(NID_IO, "[E_SECTION_ALREADY_EXIST] The registry file has the duplicated section name.");
return E_SECTION_ALREADY_EXIST;
}