Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sylvain Joubert
KWSys
Commits
11ce5611
Commit
11ce5611
authored
19 years ago
by
Andy Cedilnik
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Cleanups and expose unix registry on windows (for cygwin etc)
parent
943b9c56
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Registry.cxx
+23
-25
23 additions, 25 deletions
Registry.cxx
Registry.hxx.in
+2
-2
2 additions, 2 deletions
Registry.hxx.in
with
25 additions
and
27 deletions
Registry.cxx
+
23
−
25
View file @
11ce5611
...
...
@@ -25,16 +25,10 @@
#include
<ctype.h>
// for isspace
#include
<stdio.h>
#ifdef WIN32
#ifdef
_
WIN32
# include <windows.h>
#endif
#ifdef KWSYS_IOS_USE_ANSI
# define VTK_IOS_NOCREATE
#else
# define VTK_IOS_NOCREATE | kwsys_ios::ios::nocreate
#endif
#define BUFFER_SIZE 8192
namespace
KWSYS_NAMESPACE
{
...
...
@@ -79,7 +73,7 @@ protected:
kwsys_stl
::
string
m_TopLevel
;
bool
m_GlobalScope
;
#ifdef WIN32
#ifdef
_
WIN32
HKEY
HKey
;
#endif
// Strip trailing and ending spaces.
...
...
@@ -94,8 +88,13 @@ protected:
bool
m_SubKeySpecified
;
Registry
::
RegistryType
m_RegistryType
;
static
const
int
BUFFER_SIZE
;
};
//----------------------------------------------------------------------------
const
int
RegistryHelper
::
BUFFER_SIZE
=
8192
;
//----------------------------------------------------------------------------
Registry
::
Registry
(
Registry
::
RegistryType
registryType
)
...
...
@@ -366,7 +365,7 @@ RegistryHelper::~RegistryHelper()
bool
RegistryHelper
::
Open
(
const
char
*
toplevel
,
const
char
*
subkey
,
int
readonly
)
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
HKEY
scope
=
HKEY_CURRENT_USER
;
...
...
@@ -412,7 +411,11 @@ bool RegistryHelper::Open(const char *toplevel, const char *subkey,
ofs
.
close
();
}
kwsys_ios
::
ifstream
*
ifs
=
new
kwsys_ios
::
ifstream
(
str
.
str
().
c_str
(),
kwsys_ios
::
ios
::
in
VTK_IOS_NOCREATE
);
kwsys_ios
::
ifstream
*
ifs
=
new
kwsys_ios
::
ifstream
(
str
.
str
().
c_str
(),
kwsys_ios
::
ios
::
in
#ifndef KWSYS_IOS_USE_ANSI
|
kwsys_ios
::
ios
::
nocreate
#endif
);
if
(
!
ifs
)
{
return
false
;
...
...
@@ -469,14 +472,14 @@ bool RegistryHelper::Open(const char *toplevel, const char *subkey,
//----------------------------------------------------------------------------
bool
RegistryHelper
::
Close
()
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
int
res
;
res
=
(
RegCloseKey
(
this
->
HKey
)
==
ERROR_SUCCESS
);
return
(
res
!=
0
);
}
#e
lse
#e
ndif
if
(
m_RegistryType
==
Registry
::
UNIX_REGISTRY
)
{
int
res
=
0
;
...
...
@@ -533,7 +536,6 @@ bool RegistryHelper::Close()
m_Empty
=
1
;
return
res
;
}
#endif
return
false
;
}
...
...
@@ -541,7 +543,7 @@ bool RegistryHelper::Close()
bool
RegistryHelper
::
ReadValue
(
const
char
*
skey
,
char
*
value
)
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
int
res
=
1
;
...
...
@@ -552,7 +554,7 @@ bool RegistryHelper::ReadValue(const char *skey, char *value)
(
BYTE
*
)
value
,
&
dwSize
)
==
ERROR_SUCCESS
);
return
(
res
!=
0
);
}
#e
lse
#e
ndif
if
(
m_RegistryType
==
Registry
::
UNIX_REGISTRY
)
{
int
res
=
0
;
...
...
@@ -571,42 +573,40 @@ bool RegistryHelper::ReadValue(const char *skey, char *value)
delete
[]
key
;
return
res
;
}
#endif
return
false
;
}
//----------------------------------------------------------------------------
bool
RegistryHelper
::
DeleteKey
(
const
char
*
key
)
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
int
res
=
1
;
res
=
(
RegDeleteKey
(
this
->
HKey
,
key
)
==
ERROR_SUCCESS
);
return
(
res
!=
0
);
}
#e
lse
#e
ndif
if
(
m_RegistryType
==
Registry
::
UNIX_REGISTRY
)
{
(
void
)
key
;
int
res
=
0
;
return
res
;
}
#endif
return
false
;
}
//----------------------------------------------------------------------------
bool
RegistryHelper
::
DeleteValue
(
const
char
*
skey
)
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
int
res
=
1
;
res
=
(
RegDeleteValue
(
this
->
HKey
,
skey
)
==
ERROR_SUCCESS
);
return
(
res
!=
0
);
}
#e
lse
#e
ndif
if
(
m_RegistryType
==
Registry
::
UNIX_REGISTRY
)
{
char
*
key
=
this
->
CreateKey
(
skey
);
...
...
@@ -618,14 +618,13 @@ bool RegistryHelper::DeleteValue(const char *skey)
delete
[]
key
;
return
1
;
}
#endif
return
false
;
}
//----------------------------------------------------------------------------
bool
RegistryHelper
::
SetValue
(
const
char
*
skey
,
const
char
*
value
)
{
#ifdef WIN32
#ifdef
_
WIN32
if
(
m_RegistryType
==
Registry
::
WIN32_REGISTRY
)
{
int
res
=
1
;
...
...
@@ -635,7 +634,7 @@ bool RegistryHelper::SetValue(const char *skey, const char *value)
len
+
1
)
==
ERROR_SUCCESS
);
return
(
res
!=
0
);
}
#e
lse
#e
ndif
if
(
m_RegistryType
==
Registry
::
UNIX_REGISTRY
)
{
char
*
key
=
this
->
CreateKey
(
skey
);
...
...
@@ -647,7 +646,6 @@ bool RegistryHelper::SetValue(const char *skey, const char *value)
delete
[]
key
;
return
1
;
}
#endif
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
Registry.hxx.in
+
2
−
2
View file @
11ce5611
...
...
@@ -36,13 +36,13 @@ class @KWSYS_NAMESPACE@_EXPORT Registry
public:
enum RegistryType
{
#ifdef WIN32
#ifdef
_
WIN32
WIN32_REGISTRY,
#endif
UNIX_REGISTRY
};
#ifdef WIN32
#ifdef
_
WIN32
Registry(RegistryType registryType = WIN32_REGISTRY);
#else
Registry(RegistryType registryType = UNIX_REGISTRY);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment