summaryrefslogtreecommitdiff
path: root/registry/source
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-05-10 09:49:31 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-05-10 09:49:31 +0000
commit61123ae95e8b990e796a785f0b2b86df91560272 (patch)
treec98d63f7f7e04b6620bda53263697455851d420a /registry/source
parent9768dd5ab1dcd6915da0d73217579d66016a5755 (diff)
new string api
Diffstat (limited to 'registry/source')
-rw-r--r--registry/source/regimpl.cxx97
1 files changed, 50 insertions, 47 deletions
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index f1eba91ea997..fee71f47595b 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: regimpl.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jsc $ $Date: 2001-03-16 16:34:02 $
+ * last change: $Author: pl $ $Date: 2001-05-10 10:46:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -604,14 +604,15 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
OStoreDirectory rStoreDir;
OUStringBuffer sFullPath(sFullKeyName.getLength());
- sal_Int32 tokenCount = sFullKeyName.getTokenCount('/');
OUString token;
sFullPath.append((sal_Unicode)'/');
- for (sal_Int32 i=0; i < tokenCount; i++)
+ sal_Int32 nIndex = 0;
+ sal_Int32 nToken = 0;
+ do
{
- token = sFullKeyName.getToken(i, '/');
+ token = sFullKeyName.getToken( nToken++, '/', nIndex );
if (token.getLength())
{
if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), token, KEY_MODE_CREATE))
@@ -622,7 +623,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
sFullPath.append(token);
sFullPath.append((sal_Unicode)'/');
}
- }
+ } while( nIndex != -1 );
pKey = new ORegKey(sFullKeyName, rStoreDir, this);
*phNewKey = pKey;
@@ -1910,24 +1911,25 @@ RegError ORegistry::createLink(RegKeyHandle hKey,
OStoreDirectory rStoreDir;
OUString sFullPath(ROOT);
- sal_uInt32 tokenCount = sFullLinkName.getTokenCount('/');
- sal_uInt32 actToken = 0;
+ sal_Int32 actToken = 0;
+ sal_Int32 nIndex = 0;
OUString token;
- token = sFullLinkName.getToken(actToken, '/');
-
- while ( actToken < tokenCount && token.getLength() > 0 )
+ do
{
- if (rStoreDir.create(pKey->getStoreFile(), sFullPath, token, KEY_MODE_CREATE))
- {
- return REG_CREATE_KEY_FAILED;
- }
+ token = sFullLinkName.getToken(actToken++, '/', nIndex);
- sFullPath += token;
- sFullPath += ROOT;
+ if( token.getLength() > 0 )
+ {
+ if (rStoreDir.create(pKey->getStoreFile(), sFullPath, token, KEY_MODE_CREATE))
+ {
+ return REG_CREATE_KEY_FAILED;
+ }
- token = sFullLinkName.getToken(++actToken, '/');
- }
+ sFullPath += token;
+ sFullPath += ROOT;
+ }
+ } while( nIndex != -1 );
pKey = new ORegKey(sFullLinkName, linkTarget, rStoreDir, this);
delete pKey;
@@ -2002,8 +2004,9 @@ RegError ORegistry::deleteLink(RegKeyHandle hKey, const OUString& linkName)
OUString ORegistry::resolveLinks(ORegKey* pKey, const OUString& path, sal_Bool firstLinkOnly)
{
OUString resolvedPath(pKey->getName());
- sal_uInt32 tokenCount = path.getTokenCount('/');
- sal_uInt32 actToken = 0;
+// sal_Int32 tokenCount = path.getTokenCount('/');
+ sal_Int32 actToken = 0;
+ sal_Int32 nIndex = 0;
OUString token;
ORegKey* pLink = NULL;
@@ -2011,43 +2014,43 @@ OUString ORegistry::resolveLinks(ORegKey* pKey, const OUString& path, sal_Bool f
resolvedPath += ROOT;
if ( path.getStr()[0] == '/' )
- token = path.getToken(++actToken, '/');
- else
- token = path.getToken(actToken, '/');
+ ++actToken;
- while ( actToken < tokenCount && token.getLength() > 0 )
+ do
{
- pLink = resolveLink(pKey, resolvedPath, token);
-
- if (pLink)
+ token = path.getToken( actToken++, '/', nIndex );
+ if( token.getLength() > 0 )
{
- OUString tmpName;
- sal_Int32 lastIndex;
+ pLink = resolveLink(pKey, resolvedPath, token);
- while(pLink)
+ if (pLink)
{
- if (!insertRecursionLink(pLink))
+ OUString tmpName;
+ sal_Int32 lastIndex;
+
+ while(pLink)
{
- resetRecursionLinks();
- delete pLink;
- return OUString();
- }
+ if (!insertRecursionLink(pLink))
+ {
+ resetRecursionLinks();
+ delete pLink;
+ return OUString();
+ }
- lastIndex = resolvedPath.lastIndexOf('/');
- tmpName = resolvedPath.copy(lastIndex + 1);
- resolvedPath = resolvedPath.copy(0, lastIndex + 1);
+ lastIndex = resolvedPath.lastIndexOf('/');
+ tmpName = resolvedPath.copy(lastIndex + 1);
+ resolvedPath = resolvedPath.copy(0, lastIndex + 1);
- pLink = resolveLink(pKey, resolvedPath, tmpName);
- }
+ pLink = resolveLink(pKey, resolvedPath, tmpName);
+ }
- resetRecursionLinks();
+ resetRecursionLinks();
+ }
+ if( actToken > 1 )
+ resolvedPath += ROOT;
}
-
- token = path.getToken(++actToken, '/');
- if ( token.getLength() )
- resolvedPath += ROOT;
- }
+ } while( nIndex != -1 );
return resolvedPath;
}