e08965f856
- Fix up icon location and some scriptlets
1615 lines
62 KiB
Diff
1615 lines
62 KiB
Diff
Index: xpcom/obsolete/component/nsFileSpecImpl.cpp
|
|
===================================================================
|
|
RCS file: xpcom/obsolete/component/nsFileSpecImpl.cpp
|
|
diff -N xpcom/obsolete/component/nsFileSpecImpl.cpp
|
|
--- xpcom/obsolete/component/nsFileSpecImpl.cpp 18 Apr 2004 14:18:15 -0000 1.2
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
@@ -1,857 +0,0 @@
|
|
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
-/* ***** BEGIN LICENSE BLOCK *****
|
|
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
- *
|
|
- * The contents of this file are subject to the Mozilla Public License Version
|
|
- * 1.1 (the "License"); you may not use this file except in compliance with
|
|
- * the License. You may obtain a copy of the License at
|
|
- * http://www.mozilla.org/MPL/
|
|
- *
|
|
- * Software distributed under the License is distributed on an "AS IS" basis,
|
|
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- * for the specific language governing rights and limitations under the
|
|
- * License.
|
|
- *
|
|
- * The Original Code is mozilla.org code.
|
|
- *
|
|
- * The Initial Developer of the Original Code is
|
|
- * Netscape Communications Corporation.
|
|
- * Portions created by the Initial Developer are Copyright (C) 1998
|
|
- * the Initial Developer. All Rights Reserved.
|
|
- *
|
|
- * Contributor(s):
|
|
- * Pierre Phaneuf <pp@ludusdesign.com>
|
|
- *
|
|
- * Alternatively, the contents of this file may be used under the terms of
|
|
- * either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- * in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- * of those above. If you wish to allow use of your version of this file only
|
|
- * under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- * use your version of this file under the terms of the MPL, indicate your
|
|
- * decision by deleting the provisions above and replace them with the notice
|
|
- * and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- * the provisions above, a recipient may use your version of this file under
|
|
- * the terms of any one of the MPL, the GPL or the LGPL.
|
|
- *
|
|
- * ***** END LICENSE BLOCK ***** */
|
|
-
|
|
-#include "nsFileSpecImpl.h"// Always first, to ensure that it compiles alone.
|
|
-
|
|
-#include "nsIFileStream.h"
|
|
-#include "nsFileStream.h"
|
|
-
|
|
-#include "nsILocalFile.h"
|
|
-
|
|
-#include "prmem.h"
|
|
-
|
|
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsFileSpecImpl, nsIFileSpec)
|
|
-
|
|
-#ifdef NS_DEBUG
|
|
-#define TEST_OUT_PTR(p) \
|
|
- if (!(p)) \
|
|
- return NS_ERROR_NULL_POINTER;
|
|
-#else
|
|
-#define TEST_OUT_PTR(p)
|
|
-#endif
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsFileSpecImpl::nsFileSpecImpl()
|
|
-//----------------------------------------------------------------------------------------
|
|
- : mInputStream(nsnull)
|
|
- , mOutputStream(nsnull)
|
|
-{
|
|
-// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!");
|
|
-
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsFileSpecImpl::nsFileSpecImpl(const nsFileSpec& inSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
- : mFileSpec(inSpec)
|
|
- , mInputStream(nsnull)
|
|
- , mOutputStream(nsnull)
|
|
-{
|
|
-// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!");
|
|
-
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsFileSpecImpl::~nsFileSpecImpl()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- CloseStream();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-/* static */
|
|
-nsresult nsFileSpecImpl::MakeInterface(const nsFileSpec& inSpec, nsIFileSpec** result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsFileSpecImpl* it = new nsFileSpecImpl(inSpec);
|
|
- if (!it)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return it->QueryInterface(NS_GET_IID(nsIFileSpec), (void **) result);
|
|
-} // nsFileSpecImpl::MakeInterface
|
|
-
|
|
-#define FILESPEC(ifilespec) ((nsFileSpecImpl*)ifilespec)->mFileSpec
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::FromFileSpec(const nsIFileSpec *original)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (original) {
|
|
- nsresult rv = ((nsIFileSpec *)original)->GetFileSpec( &mFileSpec);
|
|
- if (NS_SUCCEEDED( rv))
|
|
- return mFileSpec.Error();
|
|
- else
|
|
- return( rv);
|
|
- }
|
|
- else
|
|
- return( NS_ERROR_FAILURE);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsChildOf(nsIFileSpec *possibleParent,
|
|
- PRBool *_retval)
|
|
-{
|
|
- *_retval = mFileSpec.IsChildOf(FILESPEC(possibleParent));
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-//----------------------------------------------------------------------------------------
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetURLString(char * *aURLString)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aURLString)
|
|
- if (mFileSpec.Failed())
|
|
- return mFileSpec.Error();
|
|
- nsFileURL url(mFileSpec);
|
|
- *aURLString = nsCRT::strdup(url.GetURLString());
|
|
- if (!*aURLString)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-} // nsFileSpecImpl::GetURLString
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetURLString(const char * aURLString)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec = nsFileURL(aURLString);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetUnixStyleFilePath(char * *aUnixStyleFilePath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aUnixStyleFilePath)
|
|
- if (mFileSpec.Failed())
|
|
- return mFileSpec.Error();
|
|
- nsFilePath path(mFileSpec);
|
|
- *aUnixStyleFilePath = nsCRT::strdup((const char*) path);
|
|
- if (!*aUnixStyleFilePath)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetUnixStyleFilePath(const char * aUnixStyleFilePath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec = nsFilePath(aUnixStyleFilePath);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetPersistentDescriptorString(char * *aPersistentDescriptorString)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aPersistentDescriptorString)
|
|
- if (mFileSpec.Failed())
|
|
- return mFileSpec.Error();
|
|
- nsPersistentFileDescriptor desc(mFileSpec);
|
|
- nsCAutoString data;
|
|
- desc.GetData(data);
|
|
- *aPersistentDescriptorString = ToNewCString(data);
|
|
- if (!*aPersistentDescriptorString)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetPersistentDescriptorString(const char * aPersistentDescriptorString)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsPersistentFileDescriptor desc(mFileSpec);
|
|
- desc.SetData(nsDependentCString(aPersistentDescriptorString));
|
|
- mFileSpec = desc;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetNativePath(char * *aNativePath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aNativePath)
|
|
- if (mFileSpec.Failed())
|
|
- return mFileSpec.Error();
|
|
- *aNativePath = nsCRT::strdup(mFileSpec.GetNativePathCString());
|
|
- if (!*aNativePath)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetNativePath(const char * aNativePath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec = aNativePath;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetNSPRPath(char * *aNSPRPath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aNSPRPath)
|
|
- if (mFileSpec.Failed())
|
|
- return mFileSpec.Error();
|
|
- nsNSPRPath path(mFileSpec);
|
|
- *aNSPRPath = nsCRT::strdup((const char*) path);
|
|
- if (!*aNSPRPath)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Error()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsValid(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.Valid();
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Failed(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- *_retval = mFileSpec.Failed();
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetLeafName(char * *aLeafName)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aLeafName)
|
|
- *aLeafName = mFileSpec.GetLeafName();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetLeafName(const char * aLeafName)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec.SetLeafName(aLeafName);
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetParent(nsIFileSpec * *aParent)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aParent)
|
|
- nsFileSpec parent;
|
|
- mFileSpec.GetParent(parent);
|
|
- return MakeInterface(parent, aParent);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::MakeUnique()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec.MakeUnique();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::MakeUniqueWithSuggestedName(const char *suggestedName)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec.MakeUnique(suggestedName);
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetModDate(PRUint32 *aModDate)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aModDate)
|
|
- nsFileSpec::TimeStamp stamp;
|
|
- mFileSpec.GetModDate(stamp);
|
|
- *aModDate = stamp;
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::ModDateChanged(PRUint32 oldStamp, PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.ModDateChanged(oldStamp);
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsDirectory(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.IsDirectory();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsFile(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.IsFile();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Exists(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.Exists();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsHidden(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.IsHidden();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsSymlink(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = mFileSpec.IsSymlink();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::ResolveSymlink()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- PRBool ignore;
|
|
- return mFileSpec.ResolveSymlink(ignore);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetFileSize(PRUint32 *aFileSize)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aFileSize)
|
|
- *aFileSize = mFileSpec.GetFileSize();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aDiskSpaceAvailable)
|
|
- *aDiskSpaceAvailable = mFileSpec.GetDiskSpaceAvailable();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::AppendRelativeUnixPath(const char *relativePath)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec += relativePath;
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Touch()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- // create an empty file, like the UNIX touch command.
|
|
- nsresult rv;
|
|
- rv = OpenStreamForWriting();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- rv = CloseStream();
|
|
- return rv;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::CreateDir()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec.CreateDir();
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Delete(PRBool aRecursive)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec.Delete(aRecursive);
|
|
- return mFileSpec.Error();
|
|
-}
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Truncate(PRInt32 aNewLength)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.Truncate(aNewLength);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Rename(const char *newLeafName)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.Rename(newLeafName);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::CopyToDir(const nsIFileSpec *newParentDir)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.CopyToDir(FILESPEC(newParentDir));
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::MoveToDir(const nsIFileSpec *newParentDir)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.MoveToDir(FILESPEC(newParentDir));
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Execute(const char *args)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return mFileSpec.Execute(args);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::OpenStreamForReading()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (mInputStream || mOutputStream)
|
|
- return NS_ERROR_FAILURE;
|
|
- return NS_NewTypicalInputFileStream((nsISupports**)&mInputStream, mFileSpec);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::OpenStreamForWriting()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (mInputStream || mOutputStream)
|
|
- return NS_ERROR_FAILURE;
|
|
- return NS_NewTypicalOutputFileStream((nsISupports**)&mOutputStream, mFileSpec);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::OpenStreamForReadingAndWriting()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (mInputStream || mOutputStream)
|
|
- return NS_ERROR_FAILURE;
|
|
- nsresult result = NS_NewTypicalInputFileStream((nsISupports**)&mInputStream, mFileSpec);
|
|
- if (NS_SUCCEEDED(result))
|
|
- result = NS_NewTypicalOutputFileStream((nsISupports**)&mOutputStream, mFileSpec);
|
|
- return result;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::CloseStream()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- NS_IF_RELEASE(mInputStream);
|
|
- NS_IF_RELEASE(mOutputStream);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::IsStreamOpen(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = (mInputStream || mOutputStream);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetInputStream(nsIInputStream** _retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- if (!mInputStream) {
|
|
- nsresult rv = OpenStreamForReading();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- }
|
|
- *_retval = mInputStream;
|
|
- NS_IF_ADDREF(mInputStream);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetOutputStream(nsIOutputStream** _retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- if (!mOutputStream) {
|
|
- nsresult rv = OpenStreamForWriting();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- }
|
|
- *_retval = mOutputStream;
|
|
- NS_IF_ADDREF(mOutputStream);
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetFileContents(const char* inString)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsresult rv = OpenStreamForWriting();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- PRInt32 count;
|
|
- rv = Write(inString, PL_strlen(inString), &count);
|
|
- nsresult rv2 = CloseStream();
|
|
- return NS_FAILED(rv) ? rv : rv2;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetFileContents(char** _retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- *_retval = nsnull;
|
|
- nsresult rv = OpenStreamForReading();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- PRInt32 theSize;
|
|
- rv = GetFileSize((PRUint32*)&theSize);
|
|
- if (NS_SUCCEEDED(rv))
|
|
- rv = Read(_retval, theSize, &theSize);
|
|
- if (NS_SUCCEEDED(rv))
|
|
- (*_retval)[theSize] = 0;
|
|
- nsresult rv2 = CloseStream();
|
|
- return NS_FAILED(rv) ? rv : rv2;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::GetFileSpec(nsFileSpec *aFileSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(aFileSpec)
|
|
- *aFileSpec = mFileSpec;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Equals(nsIFileSpec *spec, PRBool *result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsresult rv;
|
|
-
|
|
- if (!result || !spec) return NS_ERROR_NULL_POINTER;
|
|
-
|
|
- nsFileSpec otherSpec;
|
|
-
|
|
- rv = spec->GetFileSpec(&otherSpec);
|
|
- if (NS_FAILED(rv)) return rv;
|
|
-
|
|
- if (mFileSpec == otherSpec) {
|
|
- *result = PR_TRUE;
|
|
- }
|
|
- else {
|
|
- *result = PR_FALSE;
|
|
- }
|
|
-
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::SetFromFileSpec(const nsFileSpec& aFileSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- mFileSpec = aFileSpec;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Eof(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- if (!mInputStream)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- nsInputFileStream s(mInputStream);
|
|
- *_retval = s.eof();
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Read(char** buffer, PRInt32 requestedCount, PRInt32 *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- TEST_OUT_PTR(buffer)
|
|
- if (!mInputStream) {
|
|
- nsresult rv = OpenStreamForReading();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- }
|
|
- if (!*buffer)
|
|
- *buffer = (char*)PR_Malloc(requestedCount + 1);
|
|
- if (!mInputStream)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- nsInputFileStream s(mInputStream);
|
|
- *_retval = s.read(*buffer, requestedCount);
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::ReadLine(char** line, PRInt32 bufferSize, PRBool *wasTruncated)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(wasTruncated)
|
|
- TEST_OUT_PTR(line)
|
|
- if (!mInputStream) {
|
|
- nsresult rv = OpenStreamForReading();
|
|
- if (NS_FAILED(rv)) return rv;
|
|
- }
|
|
- if (!*line)
|
|
- *line = (char*)PR_Malloc(bufferSize + 1);
|
|
- if (!mInputStream)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- nsInputFileStream s(mInputStream);
|
|
- *wasTruncated = !s.readline(*line, bufferSize);
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Write(const char * data, PRInt32 requestedCount, PRInt32 *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- //if (!mOutputStream)
|
|
- // return NS_ERROR_NULL_POINTER;
|
|
- if (!mOutputStream) {
|
|
- nsresult rv = OpenStreamForWriting();
|
|
- if (NS_FAILED(rv))
|
|
- return rv;
|
|
- }
|
|
- nsOutputFileStream s(mOutputStream);
|
|
- *_retval = s.write(data, requestedCount);
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Flush()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (!mOutputStream)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- nsOutputFileStream s(mOutputStream);
|
|
- s.flush();
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Seek(PRInt32 offset)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsresult result = NS_OK;
|
|
- if (mOutputStream)
|
|
- {
|
|
- nsOutputFileStream os(mOutputStream);
|
|
- os.seek(offset);
|
|
- result = os.error();
|
|
- }
|
|
- if (NS_SUCCEEDED(result) && mInputStream)
|
|
- {
|
|
- nsInputFileStream is(mInputStream);
|
|
- is.seek(offset);
|
|
- result = is.error();
|
|
- }
|
|
- return result;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Tell(PRInt32 *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- if (!mInputStream)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- nsInputFileStream s(mInputStream);
|
|
- *_retval = s.tell();
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::EndLine()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsOutputFileStream s(mOutputStream);
|
|
- s << nsEndl;
|
|
- return s.error();
|
|
-}
|
|
-
|
|
-NS_IMPL_ISUPPORTS1(nsDirectoryIteratorImpl, nsIDirectoryIterator)
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsDirectoryIteratorImpl::nsDirectoryIteratorImpl()
|
|
-//----------------------------------------------------------------------------------------
|
|
- : mDirectoryIterator(nsnull)
|
|
-{
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsDirectoryIteratorImpl::~nsDirectoryIteratorImpl()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- delete mDirectoryIterator;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsDirectoryIteratorImpl::Init(nsIFileSpec *parent, PRBool resolveSymlink)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- delete mDirectoryIterator;
|
|
- mDirectoryIterator = new nsDirectoryIterator(FILESPEC(parent), resolveSymlink);
|
|
- if (!mDirectoryIterator)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsDirectoryIteratorImpl::Exists(PRBool *_retval)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- TEST_OUT_PTR(_retval)
|
|
- if (!mDirectoryIterator)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- *_retval = mDirectoryIterator->Exists();
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsDirectoryIteratorImpl::Next()
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (!mDirectoryIterator)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- (*mDirectoryIterator)++;
|
|
- return NS_OK;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsDirectoryIteratorImpl::GetCurrentSpec(nsIFileSpec * *aCurrentSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (!mDirectoryIterator)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
- return nsFileSpecImpl::MakeInterface(mDirectoryIterator->Spec(), aCurrentSpec);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsDirectoryIteratorImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aIFileSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (aIFileSpec == NULL)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
-
|
|
- nsDirectoryIteratorImpl* it = new nsDirectoryIteratorImpl;
|
|
- if (!it)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
-
|
|
- nsresult rv = it->QueryInterface(aIID, aIFileSpec);
|
|
- if (NS_FAILED(rv))
|
|
- {
|
|
- delete it;
|
|
- return rv;
|
|
- }
|
|
- return rv;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-NS_IMETHODIMP nsFileSpecImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aIFileSpec)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (aIFileSpec == NULL)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
-
|
|
- nsFileSpecImpl* it = new nsFileSpecImpl;
|
|
- if (!it)
|
|
- return NS_ERROR_OUT_OF_MEMORY;
|
|
-
|
|
- nsresult rv = it->QueryInterface(aIID, aIFileSpec);
|
|
- if (NS_FAILED(rv))
|
|
- {
|
|
- delete it;
|
|
- return rv;
|
|
- }
|
|
- return rv;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsresult NS_NewFileSpecWithSpec(const nsFileSpec& aSrcFileSpec, nsIFileSpec **result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- if (!result)
|
|
- return NS_ERROR_NULL_POINTER;
|
|
-
|
|
- return nsFileSpecImpl::MakeInterface(aSrcFileSpec, result);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsresult NS_NewFileSpec(nsIFileSpec** result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return nsFileSpecImpl::Create(nsnull, NS_GET_IID(nsIFileSpec), (void**)result);
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsresult NS_NewFileSpecFromIFile(nsIFile *aFile, nsIFileSpec **result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- nsresult rv = nsFileSpecImpl::Create(nsnull, NS_GET_IID(nsIFileSpec), (void**)result);
|
|
- if (NS_FAILED(rv)) return rv;
|
|
-
|
|
- nsCAutoString path;
|
|
- rv = aFile->GetNativePath(path);
|
|
- if (NS_FAILED(rv)) return rv;
|
|
-
|
|
- rv = (*result)->SetNativePath(path.get());
|
|
- if (NS_FAILED(rv))
|
|
- NS_RELEASE(*result);
|
|
- return rv;
|
|
-}
|
|
-
|
|
-//----------------------------------------------------------------------------------------
|
|
-nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result)
|
|
-//----------------------------------------------------------------------------------------
|
|
-{
|
|
- return nsDirectoryIteratorImpl::Create(nsnull, NS_GET_IID(nsIDirectoryIterator), (void**)result);
|
|
-}
|
|
Index: xpcom/obsolete/component/nsFileSpecImpl.h
|
|
===================================================================
|
|
RCS file: xpcom/obsolete/component/nsFileSpecImpl.h
|
|
diff -N xpcom/obsolete/component/nsFileSpecImpl.h
|
|
--- xpcom/obsolete/component/nsFileSpecImpl.h 18 Apr 2004 14:18:15 -0000 1.3
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
@@ -1,116 +0,0 @@
|
|
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
-/* ***** BEGIN LICENSE BLOCK *****
|
|
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
- *
|
|
- * The contents of this file are subject to the Mozilla Public License Version
|
|
- * 1.1 (the "License"); you may not use this file except in compliance with
|
|
- * the License. You may obtain a copy of the License at
|
|
- * http://www.mozilla.org/MPL/
|
|
- *
|
|
- * Software distributed under the License is distributed on an "AS IS" basis,
|
|
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- * for the specific language governing rights and limitations under the
|
|
- * License.
|
|
- *
|
|
- * The Original Code is mozilla.org code.
|
|
- *
|
|
- * The Initial Developer of the Original Code is
|
|
- * Netscape Communications Corporation.
|
|
- * Portions created by the Initial Developer are Copyright (C) 1998
|
|
- * the Initial Developer. All Rights Reserved.
|
|
- *
|
|
- * Contributor(s):
|
|
- *
|
|
- * Alternatively, the contents of this file may be used under the terms of
|
|
- * either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- * in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- * of those above. If you wish to allow use of your version of this file only
|
|
- * under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- * use your version of this file under the terms of the MPL, indicate your
|
|
- * decision by deleting the provisions above and replace them with the notice
|
|
- * and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- * the provisions above, a recipient may use your version of this file under
|
|
- * the terms of any one of the MPL, the GPL or the LGPL.
|
|
- *
|
|
- * ***** END LICENSE BLOCK ***** */
|
|
-
|
|
-#ifndef _FILESPECIMPL_H_
|
|
-#define _FILESPECIMPL_H_
|
|
-
|
|
-#include "nscore.h"
|
|
-#include "nsIFileSpec.h"
|
|
-#include "nsFileSpec.h"
|
|
-
|
|
-//========================================================================================
|
|
-class nsFileSpecImpl
|
|
-//========================================================================================
|
|
- : public nsIFileSpec
|
|
-{
|
|
-
|
|
- public:
|
|
-
|
|
- NS_DECL_ISUPPORTS
|
|
-
|
|
- NS_DECL_NSIFILESPEC
|
|
-
|
|
- //----------------------
|
|
- // COM Cruft
|
|
- //----------------------
|
|
-
|
|
- static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aIFileSpec);
|
|
-
|
|
- //----------------------
|
|
- // Implementation
|
|
- //----------------------
|
|
-
|
|
- nsFileSpecImpl();
|
|
- nsFileSpecImpl(const nsFileSpec& inSpec);
|
|
- static nsresult MakeInterface(const nsFileSpec& inSpec, nsIFileSpec** outSpec);
|
|
-
|
|
- //----------------------
|
|
- // Data
|
|
- //----------------------
|
|
-
|
|
- nsFileSpec mFileSpec;
|
|
- nsIInputStream* mInputStream;
|
|
- nsIOutputStream* mOutputStream;
|
|
-
|
|
-private:
|
|
- ~nsFileSpecImpl();
|
|
-}; // class nsFileSpecImpl
|
|
-
|
|
-//========================================================================================
|
|
-class nsDirectoryIteratorImpl
|
|
-//========================================================================================
|
|
- : public nsIDirectoryIterator
|
|
-{
|
|
-
|
|
-public:
|
|
-
|
|
- nsDirectoryIteratorImpl();
|
|
-
|
|
- NS_DECL_ISUPPORTS
|
|
-
|
|
- NS_IMETHOD Init(nsIFileSpec *parent, PRBool resolveSymlink);
|
|
-
|
|
- NS_IMETHOD Exists(PRBool *_retval);
|
|
-
|
|
- NS_IMETHOD Next();
|
|
-
|
|
- NS_IMETHOD GetCurrentSpec(nsIFileSpec * *aCurrentSpec);
|
|
-
|
|
- //----------------------
|
|
- // COM Cruft
|
|
- //----------------------
|
|
-
|
|
- static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aIFileSpec);
|
|
-
|
|
-private:
|
|
- ~nsDirectoryIteratorImpl();
|
|
-
|
|
-protected:
|
|
- nsDirectoryIterator* mDirectoryIterator;
|
|
-}; // class nsDirectoryIteratorImpl
|
|
-
|
|
-#endif // _FILESPECIMPL_H_
|
|
Index: xpcom/obsolete/component/nsIRegistry.idl
|
|
===================================================================
|
|
RCS file: xpcom/obsolete/component/nsIRegistry.idl
|
|
diff -N xpcom/obsolete/component/nsIRegistry.idl
|
|
--- xpcom/obsolete/component/nsIRegistry.idl 18 Apr 2004 14:18:15 -0000 1.2
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
@@ -1,186 +0,0 @@
|
|
-/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
-/* ***** BEGIN LICENSE BLOCK *****
|
|
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
- *
|
|
- * The contents of this file are subject to the Mozilla Public License Version
|
|
- * 1.1 (the "License"); you may not use this file except in compliance with
|
|
- * the License. You may obtain a copy of the License at
|
|
- * http://www.mozilla.org/MPL/
|
|
- *
|
|
- * Software distributed under the License is distributed on an "AS IS" basis,
|
|
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- * for the specific language governing rights and limitations under the
|
|
- * License.
|
|
- *
|
|
- * The Original Code is mozilla.org Code.
|
|
- *
|
|
- * The Initial Developer of the Original Code is
|
|
- * Netscape Communications Corporation.
|
|
- * Portions created by the Initial Developer are Copyright (C) 1999
|
|
- * the Initial Developer. All Rights Reserved.
|
|
- *
|
|
- * Contributor(s):
|
|
- *
|
|
- * Alternatively, the contents of this file may be used under the terms of
|
|
- * either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- * in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- * of those above. If you wish to allow use of your version of this file only
|
|
- * under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- * use your version of this file under the terms of the MPL, indicate your
|
|
- * decision by deleting the provisions above and replace them with the notice
|
|
- * and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- * the provisions above, a recipient may use your version of this file under
|
|
- * the terms of any one of the MPL, the GPL or the LGPL.
|
|
- *
|
|
- * ***** END LICENSE BLOCK ***** */
|
|
-#include "nsISupports.idl"
|
|
-#include "nsIEnumerator.idl"
|
|
-
|
|
-interface nsIFile;
|
|
-
|
|
-typedef PRUint32 nsRegistryKey;
|
|
-typedef long nsWellKnownRegistry;
|
|
-
|
|
-[scriptable,uuid(5D41A440-8E37-11d2-8059-00600811A9C3)]
|
|
-interface nsIRegistry : nsISupports
|
|
-{
|
|
- const long None = 0;
|
|
- const long Users = 1;
|
|
- const long Common = 2;
|
|
- const long CurrentUser = 3;
|
|
-
|
|
- const long ApplicationComponentRegistry = 1;
|
|
- const long ApplicationRegistry = 2;
|
|
-
|
|
- // Dont use this one. This for internal use only.
|
|
- const long ApplicationCustomRegistry = -1;
|
|
-
|
|
- void open(in nsIFile regFile);
|
|
- void openWellKnownRegistry(in nsWellKnownRegistry regid);
|
|
-
|
|
- void flush();
|
|
- boolean isOpen();
|
|
-
|
|
- nsRegistryKey addKey(in nsRegistryKey baseKey, in wstring keyname);
|
|
- nsRegistryKey getKey(in nsRegistryKey baseKey, in wstring keyname);
|
|
- void removeKey(in nsRegistryKey baseKey, in wstring keyname);
|
|
-
|
|
- wstring getString(in nsRegistryKey baseKey, in wstring valname);
|
|
- void setString(in nsRegistryKey baseKey, in wstring valname, in wstring value);
|
|
-
|
|
- string getStringUTF8(in nsRegistryKey baseKey, in string path);
|
|
- void setStringUTF8(in nsRegistryKey baseKey, in string path, in string value);
|
|
-
|
|
- void getBytesUTF8(in nsRegistryKey baseKey, in string path, out PRUint32 length, [retval, array, size_is(length)] out PRUint8 valueArray);
|
|
- void setBytesUTF8(in nsRegistryKey baseKey, in string path, in PRUint32 length, [array, size_is(length)] in PRUint8 valueArray);
|
|
- PRInt32 getInt(in nsRegistryKey baseKey, in string path);
|
|
- void setInt(in nsRegistryKey baseKey, in string path, in PRInt32 value);
|
|
- PRInt64 getLongLong(in nsRegistryKey baseKey, in string path);
|
|
- void setLongLong(in nsRegistryKey baseKey, in string path, inout PRInt64 value);
|
|
-
|
|
- /**
|
|
- * addSubtree() and friends need to be renamed to addKeyUTF8().
|
|
- * If you are using these forms make sure you pass UTF8 data
|
|
- */
|
|
- nsRegistryKey addSubtree(in nsRegistryKey baseKey, in string path);
|
|
- void removeSubtree(in nsRegistryKey baseKey, in string path);
|
|
- nsRegistryKey getSubtree(in nsRegistryKey baseKey, in string path);
|
|
-
|
|
- nsRegistryKey addSubtreeRaw(in nsRegistryKey baseKey, in string path);
|
|
- void removeSubtreeRaw(in nsRegistryKey baseKey, in string path);
|
|
- nsRegistryKey getSubtreeRaw(in nsRegistryKey baseKey, in string path);
|
|
-
|
|
- nsIEnumerator enumerateSubtrees(in nsRegistryKey baseKey);
|
|
- nsIEnumerator enumerateAllSubtrees(in nsRegistryKey baseKey);
|
|
- nsIEnumerator enumerateValues(in nsRegistryKey baseKey);
|
|
-
|
|
- const unsigned long String = 1;
|
|
- const unsigned long Int32 = 2;
|
|
- const unsigned long Bytes = 3;
|
|
- const unsigned long File = 4;
|
|
-
|
|
- unsigned long getValueType(in nsRegistryKey baseKey, in string path);
|
|
- PRUint32 getValueLength(in nsRegistryKey baseKey, in string path);
|
|
- void deleteValue(in nsRegistryKey baseKey, in string path);
|
|
-
|
|
- /**
|
|
- * escapeKey() takes arbitrary binary data and converts it into
|
|
- * valid ASCII which can be used as registry key or value names
|
|
- */
|
|
- void escapeKey([array, size_is(length)] in PRUint8 key, in PRUint32 terminator, inout PRUint32 length, [retval, array, size_is(length)] out PRUint8 escaped);
|
|
- void unescapeKey([array, size_is(length)] in PRUint8 escaped, in PRUint32 terminator, inout PRUint32 length, [retval, array, size_is(length)] out PRUint8 key);
|
|
-
|
|
- attribute string currentUserName;
|
|
-
|
|
- void pack();
|
|
-};
|
|
-
|
|
-[scriptable, uuid(8cecf236-1dd2-11b2-893c-f9848956eaec)]
|
|
-interface nsIRegistryEnumerator : nsIEnumerator
|
|
-{
|
|
- void currentItemInPlaceUTF8(out nsRegistryKey key,
|
|
- [shared, retval] out string item);
|
|
-};
|
|
-
|
|
-[scriptable, uuid(D1B54831-AC07-11d2-805E-00600811A9C3)]
|
|
-interface nsIRegistryNode : nsISupports
|
|
-{
|
|
- readonly attribute string nameUTF8;
|
|
- readonly attribute wstring name;
|
|
- readonly attribute nsRegistryKey key;
|
|
-};
|
|
-
|
|
-[scriptable,uuid(5316C380-B2F8-11d2-A374-0080C6F80E4B)]
|
|
-interface nsIRegistryValue : nsISupports
|
|
-{
|
|
- readonly attribute wstring name;
|
|
- readonly attribute string nameUTF8;
|
|
- readonly attribute unsigned long type;
|
|
- readonly attribute PRUint32 length;
|
|
-};
|
|
-
|
|
-[uuid(3A15FC88-7A61-4Ab4-8E58-31E95fAB3DA8)]
|
|
-/**
|
|
- * It sucks that nsIRegistry has to always allocate and return
|
|
- * strings. nsIRegistryGetter adds in interfaces for non allocating getters
|
|
- * to registry values.
|
|
- */
|
|
-interface nsIRegistryGetter : nsISupports
|
|
-{
|
|
- /**
|
|
- * Get a string value of attribute valname in widestring or utf8 format
|
|
- *
|
|
- * @return
|
|
- * NS_OK on success.
|
|
- * buf has the string value copied into it. length is NOT changed.
|
|
- * NS_ERROR_REG_BUFFER_TOO_SMALL if not enough buffer space.
|
|
- * length is updated to actual length in chars including
|
|
- * terminating NULL and buf will be unchanged.
|
|
- * NS_ERROR_FAILURE if an unknown error happened. state of buf and
|
|
- * length undefined.
|
|
- * various failure codes otherwise. buf and length wont be updated.
|
|
- */
|
|
- void getStringUTF8IntoBuffer(in nsRegistryKey baseKey, in string path,
|
|
- inout char buf, inout PRUint32 length);
|
|
-
|
|
- /**
|
|
- * Get a a byte array value of attribute valname
|
|
- *
|
|
- * @return
|
|
- * NS_OK on success. buf has the string value copied into it.
|
|
- * length is updated to actual number of bytes copied into buf.
|
|
- * NS_ERROR_REG_BUFFER_TOO_SMALL if not enough buffer space.
|
|
- * length is updated to actual length in PRUint8s including
|
|
- * terminating NULL and buf will be unchanged.
|
|
- * NS_ERROR_FAILURE if an unknown error happened. state of buf and
|
|
- * length undefined.
|
|
- * various other failure codes otherwise. buf and length wont be updated.
|
|
- */
|
|
- void getBytesUTF8IntoBuffer(in nsRegistryKey baseKey, in string path,
|
|
- inout PRUint8 buf, inout PRUint32 length);
|
|
-};
|
|
-
|
|
-%{ C++
|
|
-#include "nsIRegistryUtils.h"
|
|
-%}
|
|
Index: xpcom/obsolete/component/nsIRegistryUtils.h
|
|
===================================================================
|
|
RCS file: xpcom/obsolete/component/nsIRegistryUtils.h
|
|
diff -N xpcom/obsolete/component/nsIRegistryUtils.h
|
|
--- xpcom/obsolete/component/nsIRegistryUtils.h 18 Apr 2004 14:18:15 -0000 1.2
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
@@ -1,63 +0,0 @@
|
|
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
-/* ***** BEGIN LICENSE BLOCK *****
|
|
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
- *
|
|
- * The contents of this file are subject to the Mozilla Public License Version
|
|
- * 1.1 (the "License"); you may not use this file except in compliance with
|
|
- * the License. You may obtain a copy of the License at
|
|
- * http://www.mozilla.org/MPL/
|
|
- *
|
|
- * Software distributed under the License is distributed on an "AS IS" basis,
|
|
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- * for the specific language governing rights and limitations under the
|
|
- * License.
|
|
- *
|
|
- * The Original Code is mozilla.org code.
|
|
- *
|
|
- * The Initial Developer of the Original Code is
|
|
- * Netscape Communications Corporation.
|
|
- * Portions created by the Initial Developer are Copyright (C) 1998
|
|
- * the Initial Developer. All Rights Reserved.
|
|
- *
|
|
- * Contributor(s):
|
|
- *
|
|
- * Alternatively, the contents of this file may be used under the terms of
|
|
- * either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- * in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- * of those above. If you wish to allow use of your version of this file only
|
|
- * under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- * use your version of this file under the terms of the MPL, indicate your
|
|
- * decision by deleting the provisions above and replace them with the notice
|
|
- * and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- * the provisions above, a recipient may use your version of this file under
|
|
- * the terms of any one of the MPL, the GPL or the LGPL.
|
|
- *
|
|
- * ***** END LICENSE BLOCK ***** */
|
|
-#ifndef __nsIRegistryUtils_h
|
|
-#define __nsIRegistryUtils_h
|
|
-
|
|
-#define NS_REGISTRY_CONTRACTID "@mozilla.org/registry;1"
|
|
-#define NS_REGISTRY_CLASSNAME "Mozilla Registry"
|
|
-/* be761f00-a3b0-11d2-996c-0080c7cb1081 */
|
|
-#define NS_REGISTRY_CID \
|
|
-{ \
|
|
- 0xbe761f00, \
|
|
- 0xa3b0, \
|
|
- 0x11d2, \
|
|
- {0x99, 0x6c, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x81} \
|
|
-}
|
|
-
|
|
-/*------------------------------- Error Codes ----------------------------------
|
|
-------------------------------------------------------------------------------*/
|
|
-#define NS_ERROR_REG_BADTYPE NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 1 )
|
|
-#define NS_ERROR_REG_NO_MORE NS_ERROR_GENERATE_SUCCESS( NS_ERROR_MODULE_REG, 2 )
|
|
-#define NS_ERROR_REG_NOT_FOUND NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 3 )
|
|
-#define NS_ERROR_REG_NOFILE NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 4 )
|
|
-#define NS_ERROR_REG_BUFFER_TOO_SMALL NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 5 )
|
|
-#define NS_ERROR_REG_NAME_TOO_LONG NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 6 )
|
|
-#define NS_ERROR_REG_NO_PATH NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 7 )
|
|
-#define NS_ERROR_REG_READ_ONLY NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 8 )
|
|
-#define NS_ERROR_REG_BAD_UTF8 NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_REG, 9 )
|
|
-
|
|
-#endif
|
|
Index: xpcom/obsolete/component/regExport.cpp
|
|
===================================================================
|
|
RCS file: xpcom/obsolete/component/regExport.cpp
|
|
diff -N xpcom/obsolete/component/regExport.cpp
|
|
--- xpcom/obsolete/component/regExport.cpp 18 Apr 2004 14:18:15 -0000 1.2
|
|
+++ /dev/null 1 Jan 1970 00:00:00 -0000
|
|
@@ -1,357 +0,0 @@
|
|
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
-/* ***** BEGIN LICENSE BLOCK *****
|
|
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
- *
|
|
- * The contents of this file are subject to the Mozilla Public License Version
|
|
- * 1.1 (the "License"); you may not use this file except in compliance with
|
|
- * the License. You may obtain a copy of the License at
|
|
- * http://www.mozilla.org/MPL/
|
|
- *
|
|
- * Software distributed under the License is distributed on an "AS IS" basis,
|
|
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- * for the specific language governing rights and limitations under the
|
|
- * License.
|
|
- *
|
|
- * The Original Code is mozilla.org code.
|
|
- *
|
|
- * The Initial Developer of the Original Code is
|
|
- * Netscape Communications Corporation.
|
|
- * Portions created by the Initial Developer are Copyright (C) 1998
|
|
- * the Initial Developer. All Rights Reserved.
|
|
- *
|
|
- * Contributor(s):
|
|
- *
|
|
- * Alternatively, the contents of this file may be used under the terms of
|
|
- * either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- * in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- * of those above. If you wish to allow use of your version of this file only
|
|
- * under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- * use your version of this file under the terms of the MPL, indicate your
|
|
- * decision by deleting the provisions above and replace them with the notice
|
|
- * and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- * the provisions above, a recipient may use your version of this file under
|
|
- * the terms of any one of the MPL, the GPL or the LGPL.
|
|
- *
|
|
- * ***** END LICENSE BLOCK ***** */
|
|
-
|
|
-#include <stdio.h>
|
|
-
|
|
-#include "nsIServiceManager.h"
|
|
-#include "nsIComponentManager.h"
|
|
-#include "nsCOMPtr.h"
|
|
-#include "nsIRegistry.h"
|
|
-#include "nsIEnumerator.h"
|
|
-#include "nsILocalFile.h"
|
|
-#include "nsDependentString.h"
|
|
-#include "prmem.h"
|
|
-#include "plstr.h"
|
|
-#include "nsMemory.h"
|
|
-
|
|
-static void display( nsIRegistry *reg, nsRegistryKey root, const char *name );
|
|
-static void displayValues( nsIRegistry *reg, nsRegistryKey root );
|
|
-static void printString( const char *value, int indent );
|
|
-
|
|
-int main( int argc, char *argv[] ) {
|
|
-
|
|
-
|
|
-#ifdef __MWERKS__
|
|
- // Hack in some arguments. A NULL registry name is supposed to tell libreg
|
|
- // to use the default registry (which does seem to work).
|
|
- argc = 1;
|
|
- const char* myArgs[] =
|
|
- {
|
|
- "regExport"
|
|
- };
|
|
- argv = const_cast<char**>(myArgs);
|
|
-#endif
|
|
-
|
|
- nsresult rv;
|
|
-
|
|
- // Initialize XPCOM
|
|
- nsIServiceManager *servMgr = NULL;
|
|
- rv = NS_InitXPCOM2(&servMgr, NULL, NULL);
|
|
- if (NS_FAILED(rv))
|
|
- {
|
|
- // Cannot initialize XPCOM
|
|
- printf("Cannot initialize XPCOM. Exit. [rv=0x%08X]\n", (int)rv);
|
|
- exit(-1);
|
|
- }
|
|
- {
|
|
- // Get the component manager
|
|
- static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|
- nsCOMPtr<nsIComponentManager> compMgr = do_GetService(kComponentManagerCID, &rv);
|
|
- if (NS_FAILED(rv))
|
|
- {
|
|
- // Cant get component manager
|
|
- printf("Cannot get component manager from service manager.. Exit. [rv=0x%08X]\n", (int)rv);
|
|
- exit(-1);
|
|
- }
|
|
-
|
|
- nsIRegistry *reg;
|
|
-
|
|
- if (argc>1) {
|
|
- // Create the registry
|
|
- rv = compMgr->CreateInstanceByContractID(NS_REGISTRY_CONTRACTID, NULL,
|
|
- NS_GET_IID(nsIRegistry),
|
|
- (void **) ®);
|
|
- // Check result.
|
|
- if ( NS_FAILED(rv) )
|
|
- {
|
|
- printf( "Error opening registry file %s, rv=0x%08X\n", argv[1] , (int)rv );
|
|
- return rv;
|
|
- }
|
|
- // Open it against the input file name.
|
|
- nsCOMPtr<nsILocalFile> regFile;
|
|
- rv = NS_NewNativeLocalFile( nsDependentCString(argv[1]), PR_FALSE, getter_AddRefs(regFile) );
|
|
- if ( NS_FAILED(rv) ) {
|
|
- printf( "Error instantiating local file for %s, rv=0x%08X\n", argv[1], (int)rv );
|
|
- return rv;
|
|
- }
|
|
-
|
|
- rv = reg->Open( regFile );
|
|
-
|
|
- if ( rv == NS_OK )
|
|
- {
|
|
- printf( "Registry %s opened OK.\n", argv[1] );
|
|
-
|
|
- // Recurse over all 3 branches.
|
|
- display( reg, nsIRegistry::Common, "nsRegistry::Common" );
|
|
- display( reg, nsIRegistry::Users, "nsRegistry::Users" );
|
|
- }
|
|
- NS_RELEASE(reg);
|
|
- }
|
|
- else
|
|
- {
|
|
- // Called with no arguments. Print both the default registry and
|
|
- // the components registry. We already printed the default regsitry.
|
|
- // So just do the component registry.
|
|
- rv = compMgr->CreateInstanceByContractID(NS_REGISTRY_CONTRACTID, NULL,
|
|
- NS_GET_IID(nsIRegistry),
|
|
- (void **) ®);
|
|
-
|
|
- // Check result.
|
|
- if ( NS_FAILED(rv) )
|
|
- {
|
|
- printf( "Error opening creating registry instance, rv=0x%08X\n", (int)rv );
|
|
- return rv;
|
|
- }
|
|
- rv = reg->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
|
|
- if ( rv == NS_ERROR_REG_BADTYPE ) {
|
|
- printf( "\n\n\nThere is no <Application Component Registry>\n" );
|
|
- }
|
|
- else if ( rv == NS_OK ) {
|
|
-
|
|
- printf( "\n\n\nRegistry %s opened OK.\n", "<Application Component Registry>\n" );
|
|
-
|
|
- // Recurse over all 3 branches.
|
|
- display( reg, nsIRegistry::Common, "nsRegistry::Common" );
|
|
- display( reg, nsIRegistry::Users, "nsRegistry::Users" );
|
|
- }
|
|
- NS_RELEASE(reg);
|
|
- }
|
|
- }
|
|
- NS_ShutdownXPCOM( servMgr );
|
|
-
|
|
- return rv;
|
|
-}
|
|
-
|
|
-void display( nsIRegistry *reg, nsRegistryKey root, const char *rootName ) {
|
|
- // Print out key name.
|
|
- printf( "%s\n", rootName );
|
|
-
|
|
- // Make sure it isn't a "root" key.
|
|
- if ( root != nsIRegistry::Common
|
|
- &&
|
|
- root != nsIRegistry::Users
|
|
- &&
|
|
- root != nsIRegistry::CurrentUser ) {
|
|
- // Print values stored under this key.
|
|
- displayValues( reg, root );
|
|
- }
|
|
-
|
|
- // Enumerate all subkeys (immediately) under the given node.
|
|
- nsIEnumerator *keys;
|
|
- nsresult rv = reg->EnumerateSubtrees( root, &keys );
|
|
-
|
|
- // Check result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Set enumerator to beginning.
|
|
- rv = keys->First();
|
|
- // Enumerate subkeys till done.
|
|
- while( NS_SUCCEEDED( rv ) && (NS_OK != keys->IsDone()) ) {
|
|
- nsISupports *base;
|
|
- rv = keys->CurrentItem( &base );
|
|
- // Test result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Get specific interface.
|
|
- nsIRegistryNode *node;
|
|
- nsIID nodeIID = NS_IREGISTRYNODE_IID;
|
|
- rv = base->QueryInterface( nodeIID, (void**)&node );
|
|
- // Test that result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Get node name.
|
|
- char *name;
|
|
- rv = node->GetNameUTF8( &name );
|
|
- // Test result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Build complete name.
|
|
- char *fullName = new char[ PL_strlen(rootName) + PL_strlen(name) + 5 ];
|
|
- PL_strcpy( fullName, rootName );
|
|
- PL_strcat( fullName, " - " );
|
|
- PL_strcat( fullName, name );
|
|
- // Display contents under this subkey.
|
|
- nsRegistryKey key;
|
|
- rv = reg->GetSubtreeRaw( root, name, &key );
|
|
- if ( rv == NS_OK ) {
|
|
- display( reg, key, fullName );
|
|
- printf( "\n" );
|
|
- } else {
|
|
- printf( "Error getting key, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- delete [] fullName;
|
|
- } else {
|
|
- printf( "Error getting subtree name, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- // Release node.
|
|
- node->Release();
|
|
- } else {
|
|
- printf( "Error converting base node ptr to nsIRegistryNode, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- // Release item.
|
|
- base->Release();
|
|
-
|
|
- // Advance to next key.
|
|
- rv = keys->Next();
|
|
- // Check result.
|
|
- if ( NS_SUCCEEDED( rv ) ) {
|
|
- } else {
|
|
- printf( "Error advancing enumerator, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- } else {
|
|
- printf( "Error getting current item, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- }
|
|
- // Release key enumerator.
|
|
- keys->Release();
|
|
- } else {
|
|
- printf( "Error creating enumerator for %s, root=0x%08X, rv=0x%08X\n",
|
|
- rootName, (int)root, (int)rv );
|
|
- }
|
|
- return;
|
|
-}
|
|
-
|
|
-static void displayValues( nsIRegistry *reg, nsRegistryKey root ) {
|
|
- // Emumerate values at this registry location.
|
|
- nsIEnumerator *values;
|
|
- nsresult rv = reg->EnumerateValues( root, &values );
|
|
-
|
|
- // Check result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Go to beginning.
|
|
- rv = values->First();
|
|
-
|
|
- // Enumerate values till done.
|
|
- while( rv == NS_OK && (NS_OK != values->IsDone()) ) {
|
|
- nsISupports *base;
|
|
- rv = values->CurrentItem( &base );
|
|
- // Test result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Get specific interface.
|
|
- nsIRegistryValue *value;
|
|
- nsIID valueIID = NS_IREGISTRYVALUE_IID;
|
|
- rv = base->QueryInterface( valueIID, (void**)&value );
|
|
- // Test that result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Get node name.
|
|
- char *name;
|
|
- rv = value->GetNameUTF8( &name );
|
|
- // Test result.
|
|
- if ( rv == NS_OK ) {
|
|
- // Print name:
|
|
- printf( "\t\t%s", name );
|
|
- // Get info about this value.
|
|
- PRUint32 type;
|
|
- rv = reg->GetValueType( root, name, &type );
|
|
- if ( rv == NS_OK ) {
|
|
- // Print value contents.
|
|
- switch ( type ) {
|
|
- case nsIRegistry::String: {
|
|
- char *strValue;
|
|
- rv = reg->GetStringUTF8( root, name, &strValue );
|
|
- if ( rv == NS_OK ) {
|
|
- printString( strValue, strlen(name) );
|
|
- nsMemory::Free( strValue );
|
|
- } else {
|
|
- printf( "\t Error getting string value, rv=0x%08X", (int)rv );
|
|
- }
|
|
- }
|
|
- break;
|
|
-
|
|
- case nsIRegistry::Int32:
|
|
- {
|
|
- PRInt32 val = 0;
|
|
- rv = reg->GetInt( root, name, &val );
|
|
- if (NS_SUCCEEDED(rv)) {
|
|
- printf( "\t= Int32 [%d, 0x%x]", val, val);
|
|
- }
|
|
- else {
|
|
- printf( "\t Error getting int32 value, rv=%08X", (int)rv);
|
|
- }
|
|
- }
|
|
- break;
|
|
-
|
|
- case nsIRegistry::Bytes:
|
|
- printf( "\t= Bytes" );
|
|
- break;
|
|
-
|
|
- case nsIRegistry::File:
|
|
- printf( "\t= File (?)" );
|
|
- break;
|
|
-
|
|
- default:
|
|
- printf( "\t= ? (unknown type=0x%02X)", (int)type );
|
|
- break;
|
|
- }
|
|
- } else {
|
|
- printf( "\t= ? (error getting value, rv=0x%08X)", (int)rv );
|
|
- }
|
|
- printf("\n");
|
|
- nsMemory::Free( name );
|
|
- } else {
|
|
- printf( "Error getting value name, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- // Release node.
|
|
- value->Release();
|
|
- } else {
|
|
- printf( "Error converting base node ptr to nsIRegistryNode, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- // Release item.
|
|
- base->Release();
|
|
-
|
|
- // Advance to next key.
|
|
- rv = values->Next();
|
|
- // Check result.
|
|
- if ( NS_SUCCEEDED( rv ) ) {
|
|
- } else {
|
|
- printf( "Error advancing enumerator, rv=0x%08X\n", (int)rv );
|
|
- break;
|
|
- }
|
|
- } else {
|
|
- printf( "Error getting current item, rv=0x%08X\n", (int)rv );
|
|
- break;
|
|
- }
|
|
- }
|
|
-
|
|
- values->Release();
|
|
- } else {
|
|
- printf( "\t\tError enumerating values, rv=0x%08X\n", (int)rv );
|
|
- }
|
|
- return;
|
|
-}
|
|
-
|
|
-static void printString( const char *value, int /*indent*/ ) {
|
|
- // For now, just dump contents.
|
|
- printf( "\t = %s", value );
|
|
- return;
|
|
-}
|