summaryrefslogtreecommitdiff
path: root/registry
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-04-08 12:18:03 +0200
committerNoel Grandin <noel@peralex.com>2015-04-09 08:41:11 +0200
commit1bdbe0b475464402716c1c304d28376f1c37d820 (patch)
tree4ed184ad2b1ce13e3214d15eaed180c7e38bc073 /registry
parent1b0c1943788f6083b27a1e5a4d6d76373f08459b (diff)
convert REG_ constants to scoped enum
Change-Id: I11d92218c5e0678d497f8964723033e2bd8b3300
Diffstat (limited to 'registry')
-rw-r--r--registry/source/regimpl.cxx12
-rw-r--r--registry/source/regimpl.hxx5
-rw-r--r--registry/source/registry.cxx4
-rw-r--r--registry/test/testregcpp.cxx10
-rw-r--r--registry/tools/regcompare.cxx4
-rw-r--r--registry/tools/regmerge.cxx2
-rw-r--r--registry/tools/regview.cxx2
-rw-r--r--registry/workben/regtest.cxx6
8 files changed, 22 insertions, 23 deletions
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 6c0bba1fac47..876245a0d366 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -452,18 +452,18 @@ ORegistry::~ORegistry()
// initRegistry
-RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode)
+RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMode, bool bCreate)
{
RegError eRet = REG_INVALID_REGISTRY;
OStoreFile rRegFile;
storeAccessMode sAccessMode = REG_MODE_OPEN;
storeError errCode;
- if (accessMode & REG_CREATE)
+ if (bCreate)
{
sAccessMode = REG_MODE_CREATE;
}
- else if (accessMode & REG_READONLY)
+ else if (accessMode & RegAccessMode::READONLY)
{
sAccessMode = REG_MODE_OPENREAD;
m_readOnly = true;
@@ -547,7 +547,7 @@ RegError ORegistry::destroyRegistry(const OUString& regName)
{
std::unique_ptr<ORegistry> pReg(new ORegistry());
- if (!pReg->initRegistry(regName, REG_READWRITE))
+ if (!pReg->initRegistry(regName, RegAccessMode::READWRITE))
{
pReg.reset();
@@ -908,7 +908,7 @@ RegError ORegistry::loadKey(RegKeyHandle hKey, const OUString& regFileName,
ORegKey* pKey = static_cast< ORegKey* >(hKey);
std::unique_ptr< ORegistry > pReg (new ORegistry());
- _ret = pReg->initRegistry(regFileName, REG_READONLY);
+ _ret = pReg->initRegistry(regFileName, RegAccessMode::READONLY);
if (_ret != REG_NO_ERROR)
return _ret;
ORegKey* pRootKey = pReg->getRootKey();
@@ -956,7 +956,7 @@ RegError ORegistry::saveKey(RegKeyHandle hKey, const OUString& regFileName,
ORegKey* pKey = static_cast< ORegKey* >(hKey);
std::unique_ptr< ORegistry > pReg (new ORegistry());
- _ret = pReg->initRegistry(regFileName, REG_CREATE);
+ _ret = pReg->initRegistry(regFileName, RegAccessMode::READWRITE, true/*bCreate*/);
if (_ret != REG_NO_ERROR)
return _ret;
ORegKey* pRootKey = pReg->getRootKey();
diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx
index 3dc88987a29a..6d38cb796947 100644
--- a/registry/source/regimpl.hxx
+++ b/registry/source/regimpl.hxx
@@ -48,8 +48,6 @@
#define VALUE_TYPEOFFSET 1
#define VALUE_HEADEROFFSET 5
-#define REG_CREATE 0x0004 // allow write accesses
-
#define REG_GUARD(mutex) \
osl::Guard< osl::Mutex > aGuard( mutex );
@@ -68,7 +66,8 @@ public:
{ return --m_refCount; }
RegError initRegistry(const OUString& name,
- RegAccessMode accessMode);
+ RegAccessMode accessMode,
+ bool bCreate = false);
RegError closeRegistry();
diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx
index 163d9a35693b..f34f9e28e2ff 100644
--- a/registry/source/registry.cxx
+++ b/registry/source/registry.cxx
@@ -114,7 +114,7 @@ static RegError REGISTRY_CALLTYPE createRegistry(rtl_uString* registryName,
RegError ret;
ORegistry* pReg = new ORegistry();
- if ((ret = pReg->initRegistry(registryName, REG_CREATE)))
+ if ((ret = pReg->initRegistry(registryName, RegAccessMode::READWRITE, true/*bCreate*/)))
{
delete pReg;
*phRegistry = NULL;
@@ -508,7 +508,7 @@ RegError REGISTRY_CALLTYPE reg_createRegistry(rtl_uString* registryName,
RegError ret;
ORegistry* pReg = new ORegistry();
- if ((ret = pReg->initRegistry(registryName, REG_CREATE)))
+ if ((ret = pReg->initRegistry(registryName, RegAccessMode::READWRITE, true/*bCreate*/)))
{
delete pReg;
*phRegistry = NULL;
diff --git a/registry/test/testregcpp.cxx b/registry/test/testregcpp.cxx
index 532501d73859..1eb16831d31f 100644
--- a/registry/test/testregcpp.cxx
+++ b/registry/test/testregcpp.cxx
@@ -619,7 +619,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 32");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 33");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 33");
REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 34");
REG_ENSURE(!myRegistry->loadKey(rootKey, OUString("allFromTest2"),
@@ -659,7 +659,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 46");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 47");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 47");
REG_ENSURE(!myRegistry->destroy(OUString("test2.rdb")), "test_registry_CppApi error 48");
// REG_ENSURE(!myRegistry->destroy("test3.rdb"), "test_registry_CppApi error 49");
@@ -672,7 +672,7 @@ void test_registry_CppApi()
REG_ENSURE(!myRegistry->create(OUString("destroytest.rdb")), "test_registry_CppApi error 51");
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 52");
- REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), REG_READONLY), "test_registry_CppApi error 53");
+ REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), RegAccessMode::READONLY), "test_registry_CppApi error 53");
REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 54");
REG_ENSURE(myRegistry->mergeKey(rootKey, OUString("allFromTest3"),
@@ -681,10 +681,10 @@ void test_registry_CppApi()
REG_ENSURE(!rootKey.closeKey(), "test_registry_CppApi error 57");
REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 58");
- REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), REG_READWRITE), "test_registry_CppApi error 59");
+ REG_ENSURE(!myRegistry->open(OUString("destroytest.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 59");
REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 60");
- REG_ENSURE(!myRegistry->open(OUString("test.rdb"), REG_READWRITE), "test_registry_CppApi error 61");
+ REG_ENSURE(!myRegistry->open(OUString("test.rdb"), RegAccessMode::READWRITE), "test_registry_CppApi error 61");
REG_ENSURE(!myRegistry->destroy(OUString("ucrtest.rdb")), "test_registry_CppApi error 62");
REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 63");
delete(myRegistry);
diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx
index 032762d228ea..583b3f736c92 100644
--- a/registry/tools/regcompare.cxx
+++ b/registry/tools/regcompare.cxx
@@ -1975,13 +1975,13 @@ int _cdecl main( int argc, char * argv[] )
OUString regName2( convertToFileUrl(options.getRegName2().c_str(), options.getRegName2().size()) );
Registry reg1, reg2;
- if ( reg1.open(regName1, REG_READONLY) )
+ if ( reg1.open(regName1, RegAccessMode::READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
options.getProgramName().c_str(), options.getRegName1().c_str());
return 2;
}
- if ( reg2.open(regName2, REG_READONLY) )
+ if ( reg2.open(regName2, RegAccessMode::READONLY) )
{
fprintf(stdout, "%s: open registry \"%s\" failed\n",
options.getProgramName().c_str(), options.getRegName2().c_str());
diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx
index 0a712cae987b..7a170d72f925 100644
--- a/registry/tools/regmerge.cxx
+++ b/registry/tools/regmerge.cxx
@@ -109,7 +109,7 @@ int __cdecl main( int argc, char * argv[] )
Registry reg;
OUString regName( convertToFileUrl(args[0].c_str(), args[0].size()) );
- if (reg.open(regName, REG_READWRITE) != REG_NO_ERROR)
+ if (reg.open(regName, RegAccessMode::READWRITE) != REG_NO_ERROR)
{
if (reg.create(regName) != REG_NO_ERROR)
{
diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx
index 16b1b17a5060..6930a8fcc073 100644
--- a/registry/tools/regview.cxx
+++ b/registry/tools/regview.cxx
@@ -44,7 +44,7 @@ int __cdecl main( int argc, char * argv[] )
}
OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
- if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
+ if (reg_openRegistry(regName.pData, &hReg, RegAccessMode::READONLY))
{
fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
exit(1);
diff --git a/registry/workben/regtest.cxx b/registry/workben/regtest.cxx
index 7b590774c1ce..2a891f7a0b6a 100644
--- a/registry/workben/regtest.cxx
+++ b/registry/workben/regtest.cxx
@@ -232,7 +232,7 @@ int _cdecl main()
else
cout << "30. registry test5.rdb is closed\n";
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg, REG_READWRITE))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg, RegAccessMode::READWRITE))
cout << "\t31. registry test4.rdb is opened\n";
else
cout << "31. registry test4.rdb is opened\n";
@@ -293,13 +293,13 @@ int _cdecl main()
else
cout << "\n43. key \"/allFromTest3/reg2FirstKey/reg2FirstSubKey\" is deleted\n";
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg2, REG_READONLY))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg2, RegAccessMode::READONLY))
cout << "\n\t44. registry test4.rdb is opened for read only\n";
else
cout << "\n44. registry test4.rdb is opened for read only\n";
RegHandle hReg3;
- if (reg_openRegistry(OUString("test4.rdb").pData, &hReg3, REG_READONLY))
+ if (reg_openRegistry(OUString("test4.rdb").pData, &hReg3, RegAccessMode::READONLY))
cout << "\n\t44.a). registry test4.rdb is opened for read only\n";
else
cout << "\n44.a). registry test4.rdb is opened for read only\n";