LCOV - code coverage report
Current view: directory - xpcom/io - nsDirectoryService.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 246 173 70.3 %
Date: 2012-06-02 Functions: 22 17 77.3 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: sw=4 ts=4 sts=4 et
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   IBM Corp.
      25                 :  *   Fredrik Holmqvist <thesuckiestemail@yahoo.se>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #include "mozilla/Util.h"
      42                 : 
      43                 : #include "nsCOMPtr.h"
      44                 : #include "nsAutoPtr.h"
      45                 : #include "nsDirectoryService.h"
      46                 : #include "nsDirectoryServiceDefs.h"
      47                 : #include "nsLocalFile.h"
      48                 : #include "nsDebug.h"
      49                 : #include "nsStaticAtom.h"
      50                 : #include "nsEnumeratorUtils.h"
      51                 : 
      52                 : #include "nsICategoryManager.h"
      53                 : #include "nsISimpleEnumerator.h"
      54                 : #include "nsIStringEnumerator.h"
      55                 : 
      56                 : #if defined(XP_WIN)
      57                 : #include <windows.h>
      58                 : #include <shlobj.h>
      59                 : #include <stdlib.h>
      60                 : #include <stdio.h>
      61                 : #elif defined(XP_UNIX)
      62                 : #include <unistd.h>
      63                 : #include <stdlib.h>
      64                 : #include <sys/param.h>
      65                 : #include "prenv.h"
      66                 : #ifdef MOZ_WIDGET_COCOA
      67                 : #include <CoreServices/CoreServices.h>
      68                 : #include <Carbon/Carbon.h>
      69                 : #endif
      70                 : #elif defined(XP_OS2)
      71                 : #define MAX_PATH _MAX_PATH
      72                 : #endif
      73                 : 
      74                 : #include "SpecialSystemDirectory.h"
      75                 : #include "nsAppFileLocationProvider.h"
      76                 : 
      77                 : using namespace mozilla;
      78                 : 
      79                 : #define COMPONENT_DIRECTORY     NS_LITERAL_CSTRING("components")
      80                 : 
      81                 : // define home directory
      82                 : // For Windows platform, We are choosing Appdata folder as HOME
      83                 : #if defined (XP_WIN)
      84                 : #define HOME_DIR NS_WIN_APPDATA_DIR
      85                 : #elif defined (MOZ_WIDGET_COCOA)
      86                 : #define HOME_DIR NS_OSX_HOME_DIR
      87                 : #elif defined (XP_UNIX)
      88                 : #define HOME_DIR NS_UNIX_HOME_DIR
      89                 : #elif defined (XP_OS2)
      90                 : #define HOME_DIR NS_OS2_HOME_DIR
      91                 : #endif
      92                 : 
      93                 : //----------------------------------------------------------------------------------------
      94                 : nsresult 
      95            2334 : nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
      96                 : //----------------------------------------------------------------------------------------
      97                 : {
      98            2334 :     NS_ENSURE_ARG_POINTER(aFile);
      99            2334 :     *aFile = nsnull;
     100                 :     
     101                 :    //  Set the component registry location:
     102            2334 :     if (!gService)
     103               0 :         return NS_ERROR_FAILURE;
     104                 : 
     105                 :     nsresult rv; 
     106                 :  
     107            4668 :     nsCOMPtr<nsIProperties> dirService;
     108                 :     rv = nsDirectoryService::Create(nsnull, 
     109                 :                                     NS_GET_IID(nsIProperties), 
     110            2334 :                                     getter_AddRefs(dirService));  // needs to be around for life of product
     111                 : 
     112            2334 :     if (dirService)
     113                 :     {
     114            4668 :       nsCOMPtr <nsILocalFile> aLocalFile;
     115            2334 :       dirService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(aLocalFile));
     116            2334 :       if (aLocalFile)
     117                 :       {
     118            2267 :         *aFile = aLocalFile;
     119            2267 :         NS_ADDREF(*aFile);
     120            2267 :         return NS_OK;
     121                 :       }
     122                 :     }
     123                 : 
     124              67 :     nsLocalFile* localFile = new nsLocalFile;
     125                 : 
     126              67 :     if (localFile == nsnull)
     127               0 :         return NS_ERROR_OUT_OF_MEMORY;
     128              67 :     NS_ADDREF(localFile);
     129                 : 
     130                 : 
     131                 : 
     132                 : #ifdef XP_WIN
     133                 :     PRUnichar buf[MAX_PATH + 1];
     134                 :     SetLastError(ERROR_SUCCESS);
     135                 :     if (GetModuleFileNameW(0, buf, mozilla::ArrayLength(buf)) &&
     136                 :         GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
     137                 :         // chop off the executable name by finding the rightmost backslash
     138                 :         PRUnichar* lastSlash = wcsrchr(buf, L'\\');
     139                 :         if (lastSlash)
     140                 :             *(lastSlash + 1) = L'\0';
     141                 : 
     142                 :         localFile->InitWithPath(nsDependentString(buf));
     143                 :         *aFile = localFile;
     144                 :         return NS_OK;
     145                 :     }
     146                 : 
     147                 : #elif defined(MOZ_WIDGET_COCOA)
     148                 :     // Works even if we're not bundled.
     149                 :     CFBundleRef appBundle = CFBundleGetMainBundle();
     150                 :     if (appBundle != nsnull)
     151                 :     {
     152                 :         CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle);
     153                 :         if (bundleURL != nsnull)
     154                 :         {
     155                 :             CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, bundleURL);
     156                 :             if (parentURL)
     157                 :             {
     158                 :                 // Pass true for the "resolveAgainstBase" arg to CFURLGetFileSystemRepresentation.
     159                 :                 // This will resolve the relative portion of the CFURL against it base, giving a full
     160                 :                 // path, which CFURLCopyFileSystemPath doesn't do.
     161                 :                 char buffer[PATH_MAX];
     162                 :                 if (CFURLGetFileSystemRepresentation(parentURL, true, (UInt8 *)buffer, sizeof(buffer)))
     163                 :                 {
     164                 : #ifdef DEBUG_conrad
     165                 :                     printf("nsDirectoryService - CurrentProcessDir is: %s\n", buffer);
     166                 : #endif
     167                 :                     rv = localFile->InitWithNativePath(nsDependentCString(buffer));
     168                 :                     if (NS_SUCCEEDED(rv))
     169                 :                         *aFile = localFile;
     170                 :                 }
     171                 :                 CFRelease(parentURL);
     172                 :             }
     173                 :             CFRelease(bundleURL);
     174                 :         }
     175                 :     }
     176                 :     
     177                 :     NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n");
     178                 :     if (*aFile)
     179                 :         return NS_OK;
     180                 : 
     181                 : #elif defined(XP_UNIX)
     182                 : 
     183                 :     // In the absence of a good way to get the executable directory let
     184                 :     // us try this for unix:
     185                 :     //    - if MOZILLA_FIVE_HOME is defined, that is it
     186                 :     //    - else give the current directory
     187                 :     char buf[MAXPATHLEN];
     188                 : 
     189                 :     // The MOZ_DEFAULT_MOZILLA_FIVE_HOME variable can be set at configure time with
     190                 :     // a --with-default-mozilla-five-home=foo autoconf flag.
     191                 :     // 
     192                 :     // The idea here is to allow for builds that have a default MOZILLA_FIVE_HOME
     193                 :     // regardless of the environment.  This makes it easier to write apps that
     194                 :     // embed mozilla without having to worry about setting up the environment 
     195                 :     //
     196                 :     // We do this by putenv()ing the default value into the environment.  Note that
     197                 :     // we only do this if it is not already set.
     198                 : #ifdef MOZ_DEFAULT_MOZILLA_FIVE_HOME
     199                 :     const char *home = PR_GetEnv("MOZILLA_FIVE_HOME");
     200                 :     if (!home || !*home)
     201                 :     {
     202                 :         putenv("MOZILLA_FIVE_HOME=" MOZ_DEFAULT_MOZILLA_FIVE_HOME);
     203                 :     }
     204                 : #endif
     205                 : 
     206              67 :     char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME");
     207              67 :     if (moz5 && *moz5)
     208                 :     {
     209              67 :         if (realpath(moz5, buf)) {
     210              67 :             localFile->InitWithNativePath(nsDependentCString(buf));
     211              67 :             *aFile = localFile;
     212              67 :             return NS_OK;
     213                 :         }
     214                 :     }
     215                 : #if defined(DEBUG)
     216                 :     static bool firstWarning = true;
     217                 : 
     218               0 :     if((!moz5 || !*moz5) && firstWarning) {
     219                 :         // Warn that MOZILLA_FIVE_HOME not set, once.
     220               0 :         printf("Warning: MOZILLA_FIVE_HOME not set.\n");
     221               0 :         firstWarning = false;
     222                 :     }
     223                 : #endif /* DEBUG */
     224                 : 
     225                 :     // Fall back to current directory.
     226               0 :     if (getcwd(buf, sizeof(buf)))
     227                 :     {
     228               0 :         localFile->InitWithNativePath(nsDependentCString(buf));
     229               0 :         *aFile = localFile;
     230               0 :         return NS_OK;
     231                 :     }
     232                 : 
     233                 : #elif defined(XP_OS2)
     234                 :     PPIB ppib;
     235                 :     PTIB ptib;
     236                 :     char buffer[CCHMAXPATH];
     237                 :     DosGetInfoBlocks( &ptib, &ppib);
     238                 :     DosQueryModuleName( ppib->pib_hmte, CCHMAXPATH, buffer);
     239                 :     *strrchr( buffer, '\\') = '\0'; // XXX DBCS misery
     240                 :     localFile->InitWithNativePath(nsDependentCString(buffer));
     241                 :     *aFile = localFile;
     242                 :     return NS_OK;
     243                 : 
     244                 : #endif
     245                 :     
     246               0 :     NS_RELEASE(localFile);
     247                 : 
     248               0 :     NS_ERROR("unable to get current process directory");
     249               0 :     return NS_ERROR_FAILURE;
     250                 : } // GetCurrentProcessDirectory()
     251                 : 
     252                 : nsDirectoryService* nsDirectoryService::gService = nsnull;
     253                 : 
     254            1419 : nsDirectoryService::nsDirectoryService() :
     255            1419 :     mHashtable(256, true)
     256                 : {
     257            1419 : }
     258                 : 
     259                 : nsresult
     260            6592 : nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
     261                 : {
     262            6592 :     NS_ENSURE_ARG_POINTER(aResult);
     263            6592 :     NS_ENSURE_NO_AGGREGATION(outer);
     264                 : 
     265            6592 :     if (!gService)
     266                 :     {
     267               0 :         return NS_ERROR_NOT_INITIALIZED;
     268                 :     }
     269                 : 
     270            6592 :     return gService->QueryInterface(aIID, aResult);
     271                 : }
     272                 : 
     273                 : #define DIR_ATOM(name_, value_) nsIAtom* nsDirectoryService::name_ = nsnull;
     274                 : #include "nsDirectoryServiceAtomList.h"
     275                 : #undef DIR_ATOM
     276                 : 
     277                 : #define DIR_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
     278                 : #include "nsDirectoryServiceAtomList.h"
     279                 : #undef DIR_ATOM
     280                 : 
     281                 : static const nsStaticAtom directory_atoms[] = {
     282                 : #define DIR_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &nsDirectoryService::name_),
     283                 : #include "nsDirectoryServiceAtomList.h"
     284                 : #undef DIR_ATOM
     285                 : };    
     286                 : 
     287                 : NS_IMETHODIMP
     288               0 : nsDirectoryService::Init()
     289                 : {
     290               0 :     NS_NOTREACHED("nsDirectoryService::Init() for internal use only!");
     291               0 :     return NS_OK;
     292                 : }
     293                 : 
     294                 : nsresult
     295            1419 : nsDirectoryService::RealInit()
     296                 : {
     297            1419 :     NS_ASSERTION(!gService, 
     298                 :                  "nsDirectoryService::RealInit Mustn't initialize twice!");
     299                 : 
     300                 :     nsresult rv;
     301                 : 
     302            2838 :     nsRefPtr<nsDirectoryService> self = new nsDirectoryService();
     303            1419 :     if (!self)
     304               0 :         return NS_ERROR_OUT_OF_MEMORY;
     305                 : 
     306            1419 :     rv = NS_NewISupportsArray(getter_AddRefs(((nsDirectoryService*) self)->mProviders));
     307            1419 :     if (NS_FAILED(rv))
     308               0 :         return rv;
     309                 : 
     310            1419 :     NS_RegisterStaticAtoms(directory_atoms);
     311                 :     
     312                 :     // Let the list hold the only reference to the provider.
     313            1419 :     nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider;
     314            1419 :     if (!defaultProvider)
     315               0 :         return NS_ERROR_OUT_OF_MEMORY;
     316                 :     // AppendElement returns true for success.
     317            1419 :     rv = ((nsDirectoryService*) self)->mProviders->AppendElement(defaultProvider) ? NS_OK : NS_ERROR_FAILURE;
     318            1419 :     if (NS_FAILED(rv))
     319               0 :         return rv;
     320                 : 
     321            1419 :     self.swap(gService);
     322            1419 :     return NS_OK;
     323                 : }
     324                 : 
     325                 : bool
     326               0 : nsDirectoryService::ReleaseValues(nsHashKey* key, void* data, void* closure)
     327                 : {
     328               0 :     nsISupports* value = (nsISupports*)data;
     329               0 :     NS_IF_RELEASE(value);
     330               0 :     return true;
     331                 : }
     332                 : 
     333            1419 : nsDirectoryService::~nsDirectoryService()
     334                 : {
     335            1419 : }
     336                 : 
     337          335802 : NS_IMPL_THREADSAFE_ISUPPORTS4(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
     338                 : 
     339                 : 
     340                 : NS_IMETHODIMP
     341               0 : nsDirectoryService::Undefine(const char* prop)
     342                 : {
     343               0 :     NS_ENSURE_ARG(prop);
     344                 : 
     345               0 :     nsCStringKey key(prop);
     346               0 :     if (!mHashtable.Exists(&key))
     347               0 :         return NS_ERROR_FAILURE;
     348                 : 
     349               0 :     mHashtable.Remove (&key);
     350               0 :     return NS_OK;
     351                 :  }
     352                 : 
     353                 : NS_IMETHODIMP
     354               0 : nsDirectoryService::GetKeys(PRUint32 *count, char ***keys)
     355                 : {
     356               0 :     return NS_ERROR_NOT_IMPLEMENTED;
     357                 : }
     358                 : 
     359                 : struct FileData
     360                 : {
     361           20182 :   FileData(const char* aProperty,
     362                 :            const nsIID& aUUID) :
     363                 :     property(aProperty),
     364                 :     data(nsnull),
     365                 :     persistent(true),
     366           20182 :     uuid(aUUID) {}
     367                 :     
     368                 :   const char*   property;
     369                 :   nsISupports*  data;
     370                 :   bool          persistent;
     371                 :   const nsIID&  uuid;
     372                 : };
     373                 : 
     374           70139 : static bool FindProviderFile(nsISupports* aElement, void *aData)
     375                 : {
     376                 :   nsresult rv;
     377           70139 :   FileData* fileData = (FileData*)aData;
     378           70139 :   if (fileData->uuid.Equals(NS_GET_IID(nsISimpleEnumerator)))
     379                 :   {
     380                 :       // Not all providers implement this iface
     381           13596 :       nsCOMPtr<nsIDirectoryServiceProvider2> prov2 = do_QueryInterface(aElement);
     382            6798 :       if (prov2)
     383                 :       {
     384           12928 :           nsCOMPtr<nsISimpleEnumerator> newFiles;
     385            6464 :           rv = prov2->GetFiles(fileData->property, getter_AddRefs(newFiles));
     386            6464 :           if (NS_SUCCEEDED(rv) && newFiles) {
     387            1564 :               if (fileData->data) {
     388               0 :                   nsCOMPtr<nsISimpleEnumerator> unionFiles;
     389                 : 
     390               0 :                   NS_NewUnionEnumerator(getter_AddRefs(unionFiles),
     391               0 :                                         (nsISimpleEnumerator*) fileData->data, newFiles);
     392                 : 
     393               0 :                   if (unionFiles)
     394               0 :                       unionFiles.swap(* (nsISimpleEnumerator**) &fileData->data);
     395                 :               }
     396                 :               else
     397                 :               {
     398            1564 :                   NS_ADDREF(fileData->data = newFiles);
     399                 :               }
     400                 :                   
     401            1564 :               fileData->persistent = false; // Enumerators can never be persistent
     402            1564 :               return rv == NS_SUCCESS_AGGREGATE_RESULT;
     403                 :           }
     404                 :       }
     405                 :   }
     406                 :   else
     407                 :   {
     408          126682 :       nsCOMPtr<nsIDirectoryServiceProvider> prov = do_QueryInterface(aElement);
     409           63341 :       if (prov)
     410                 :       {
     411           63341 :           rv = prov->GetFile(fileData->property, &fileData->persistent, (nsIFile **)&fileData->data);
     412           63341 :           if (NS_SUCCEEDED(rv) && fileData->data)
     413            9745 :               return false;
     414                 :       }
     415                 :   }
     416                 : 
     417           58830 :   return true;
     418                 : }
     419                 : 
     420                 : NS_IMETHODIMP
     421           66048 : nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
     422                 : {
     423           66048 :     NS_ENSURE_ARG(prop);
     424                 : 
     425          132096 :     nsCStringKey key(prop);
     426                 :     
     427          132096 :     nsCOMPtr<nsISupports> value = dont_AddRef(mHashtable.Get(&key));
     428                 :     
     429           66048 :     if (value)
     430                 :     {
     431           91732 :         nsCOMPtr<nsIFile> cloneFile;
     432           91732 :         nsCOMPtr<nsIFile> cachedFile = do_QueryInterface(value);
     433           45866 :         NS_ASSERTION(cachedFile, 
     434                 :                      "nsDirectoryService::Get nsIFile expected");
     435                 : 
     436           45866 :         cachedFile->Clone(getter_AddRefs(cloneFile));
     437           45866 :         return cloneFile->QueryInterface(uuid, result);
     438                 :     }
     439                 : 
     440                 :     // it is not one of our defaults, lets check any providers
     441           20182 :     FileData fileData(prop, uuid);
     442                 : 
     443           20182 :     mProviders->EnumerateBackwards(FindProviderFile, &fileData);
     444           20182 :     if (fileData.data)
     445                 :     {
     446            7492 :         if (fileData.persistent)
     447                 :         {
     448            5922 :             Set(prop, static_cast<nsIFile*>(fileData.data));
     449                 :         }
     450            7492 :         nsresult rv = (fileData.data)->QueryInterface(uuid, result);
     451            7492 :         NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
     452            7492 :         return rv;
     453                 :     }
     454                 : 
     455           12690 :     FindProviderFile(static_cast<nsIDirectoryServiceProvider*>(this), &fileData);
     456           12690 :     if (fileData.data)
     457                 :     {
     458            3817 :         if (fileData.persistent)
     459                 :         {
     460            3817 :             Set(prop, static_cast<nsIFile*>(fileData.data));
     461                 :         }
     462            3817 :         nsresult rv = (fileData.data)->QueryInterface(uuid, result);
     463            3817 :         NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
     464            3817 :         return rv;
     465                 :     }
     466                 : 
     467            8873 :     return NS_ERROR_FAILURE;
     468                 : }
     469                 : 
     470                 : NS_IMETHODIMP
     471           12545 : nsDirectoryService::Set(const char* prop, nsISupports* value)
     472                 : {
     473           12545 :     NS_ENSURE_ARG(prop);
     474                 : 
     475           25090 :     nsCStringKey key(prop);
     476           12545 :     if (mHashtable.Exists(&key) || value == nsnull)
     477               0 :         return NS_ERROR_FAILURE;
     478                 : 
     479           25090 :     nsCOMPtr<nsIFile> ourFile;
     480           12545 :     value->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(ourFile));
     481           12545 :     if (ourFile)
     482                 :     {
     483           25090 :       nsCOMPtr<nsIFile> cloneFile;
     484           12545 :       ourFile->Clone (getter_AddRefs (cloneFile));
     485           12545 :       mHashtable.Put(&key, cloneFile);
     486                 : 
     487           12545 :       return NS_OK;
     488                 :     }
     489                 : 
     490               0 :     return NS_ERROR_FAILURE;   
     491                 : }
     492                 : 
     493                 : NS_IMETHODIMP
     494               0 : nsDirectoryService::Has(const char *prop, bool *_retval)
     495                 : {
     496               0 :     NS_ENSURE_ARG(prop);
     497                 : 
     498               0 :     *_retval = false;
     499               0 :     nsCOMPtr<nsIFile> value;
     500               0 :     nsresult rv = Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(value));
     501               0 :     if (NS_FAILED(rv))
     502               0 :         return NS_OK;
     503                 :     
     504               0 :     if (value)
     505                 :     {
     506               0 :         *_retval = true;
     507                 :     }
     508                 :     
     509               0 :     return rv;
     510                 : }
     511                 : 
     512                 : NS_IMETHODIMP
     513            5483 : nsDirectoryService::RegisterProvider(nsIDirectoryServiceProvider *prov)
     514                 : {
     515                 :     nsresult rv;
     516            5483 :     if (!prov)
     517               0 :         return NS_ERROR_FAILURE;
     518            5483 :     if (!mProviders)
     519               0 :         return NS_ERROR_NOT_INITIALIZED;
     520                 : 
     521           10966 :     nsCOMPtr<nsISupports> supports = do_QueryInterface(prov, &rv);
     522            5483 :     if (NS_FAILED(rv)) return rv;
     523                 : 
     524                 :     // AppendElement returns true for success.
     525            5483 :     return mProviders->AppendElement(supports) ? NS_OK : NS_ERROR_FAILURE;
     526                 : }
     527                 : 
     528                 : void
     529            1419 : nsDirectoryService::RegisterCategoryProviders()
     530                 : {
     531                 :     nsCOMPtr<nsICategoryManager> catman
     532            2838 :         (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
     533            1419 :     if (!catman)
     534                 :         return;
     535                 : 
     536            2838 :     nsCOMPtr<nsISimpleEnumerator> entries;
     537            1419 :     catman->EnumerateCategory(XPCOM_DIRECTORY_PROVIDER_CATEGORY,
     538            1419 :                               getter_AddRefs(entries));
     539                 : 
     540            2838 :     nsCOMPtr<nsIUTF8StringEnumerator> strings(do_QueryInterface(entries));
     541            1419 :     if (!strings)
     542                 :         return;
     543                 : 
     544                 :     bool more;
     545            5676 :     while (NS_SUCCEEDED(strings->HasMore(&more)) && more) {
     546            5676 :         nsCAutoString entry;
     547            2838 :         strings->GetNext(entry);
     548                 : 
     549            5676 :         nsXPIDLCString contractID;
     550            2838 :         catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));
     551                 : 
     552            2838 :         if (contractID) {
     553            5676 :             nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());
     554            2838 :             if (provider)
     555            2838 :                 RegisterProvider(provider);
     556                 :         }
     557                 :     }
     558                 : }
     559                 : 
     560                 : NS_IMETHODIMP
     561              35 : nsDirectoryService::UnregisterProvider(nsIDirectoryServiceProvider *prov)
     562                 : {
     563                 :     nsresult rv;
     564              35 :     if (!prov)
     565               0 :         return NS_ERROR_FAILURE;
     566              35 :     if (!mProviders)
     567               0 :         return NS_ERROR_NOT_INITIALIZED;
     568                 : 
     569              70 :     nsCOMPtr<nsISupports> supports = do_QueryInterface(prov, &rv);
     570              35 :     if (NS_FAILED(rv)) return rv;
     571                 : 
     572                 :     // RemoveElement returns true for success.
     573              35 :     return mProviders->RemoveElement(supports) ? NS_OK : NS_ERROR_FAILURE;
     574                 : }
     575                 : 
     576                 : // DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com.
     577                 : // This is meant to be a place of xpcom or system specific file locations, not
     578                 : // application specific locations.  If you need the later, register a callback for
     579                 : // your application.  
     580                 : 
     581                 : NS_IMETHODIMP
     582           11234 : nsDirectoryService::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
     583                 : {
     584           22468 :     nsCOMPtr<nsILocalFile> localFile;
     585           11234 :     nsresult rv = NS_ERROR_FAILURE;
     586                 : 
     587           11234 :     *_retval = nsnull;
     588           11234 :     *persistent = true;
     589                 : 
     590           22468 :     nsCOMPtr<nsIAtom> inAtom = do_GetAtom(prop);
     591                 : 
     592                 :     // check to see if it is one of our defaults
     593                 :         
     594           21049 :     if (inAtom == nsDirectoryService::sCurrentProcess || 
     595            9815 :         inAtom == nsDirectoryService::sOS_CurrentProcessDirectory )
     596                 :     {
     597            2301 :         rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
     598                 :     }
     599                 :     
     600                 :     // Unless otherwise set, the core pieces of the GRE exist
     601                 :     // in the current process directory.
     602            8933 :     else if (inAtom == nsDirectoryService::sGRE_Directory)
     603                 :     {
     604              33 :         rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
     605                 :     }
     606            8900 :     else if (inAtom == nsDirectoryService::sOS_DriveDirectory)
     607                 :     {
     608               0 :         rv = GetSpecialSystemDirectory(OS_DriveDirectory, getter_AddRefs(localFile));
     609                 :     }
     610            8900 :     else if (inAtom == nsDirectoryService::sOS_TemporaryDirectory)
     611                 :     {
     612              66 :         rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(localFile));
     613                 :     }
     614            8834 :     else if (inAtom == nsDirectoryService::sOS_CurrentProcessDirectory)
     615                 :     {
     616               0 :         rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile)); 
     617                 :     }
     618            8834 :     else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory)
     619                 :     {
     620            1386 :         rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); 
     621                 :     }
     622                 :        
     623                 : #if defined(MOZ_WIDGET_COCOA)
     624                 :     else if (inAtom == nsDirectoryService::sDirectory)
     625                 :     {
     626                 :         rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile));
     627                 :     }
     628                 :     else if (inAtom == nsDirectoryService::sTrashDirectory)
     629                 :     {
     630                 :         rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile));
     631                 :     }
     632                 :     else if (inAtom == nsDirectoryService::sStartupDirectory)
     633                 :     {
     634                 :         rv = GetOSXFolderType(kClassicDomain, kStartupFolderType, getter_AddRefs(localFile));
     635                 :     }
     636                 :     else if (inAtom == nsDirectoryService::sShutdownDirectory)
     637                 :     {
     638                 :         rv = GetOSXFolderType(kClassicDomain, kShutdownFolderType, getter_AddRefs(localFile));
     639                 :     }
     640                 :     else if (inAtom == nsDirectoryService::sAppleMenuDirectory)
     641                 :     {
     642                 :         rv = GetOSXFolderType(kClassicDomain, kAppleMenuFolderType, getter_AddRefs(localFile));
     643                 :     }
     644                 :     else if (inAtom == nsDirectoryService::sControlPanelDirectory)
     645                 :     {
     646                 :         rv = GetOSXFolderType(kClassicDomain, kControlPanelFolderType, getter_AddRefs(localFile));
     647                 :     }
     648                 :     else if (inAtom == nsDirectoryService::sExtensionDirectory)
     649                 :     {
     650                 :         rv = GetOSXFolderType(kClassicDomain, kExtensionFolderType, getter_AddRefs(localFile));
     651                 :     }
     652                 :     else if (inAtom == nsDirectoryService::sFontsDirectory)
     653                 :     {
     654                 :         rv = GetOSXFolderType(kClassicDomain, kFontsFolderType, getter_AddRefs(localFile));
     655                 :     }
     656                 :     else if (inAtom == nsDirectoryService::sPreferencesDirectory)
     657                 :     {
     658                 :         rv = GetOSXFolderType(kClassicDomain, kPreferencesFolderType, getter_AddRefs(localFile));
     659                 :     }
     660                 :     else if (inAtom == nsDirectoryService::sDocumentsDirectory)
     661                 :     {
     662                 :         rv = GetOSXFolderType(kClassicDomain, kDocumentsFolderType, getter_AddRefs(localFile));
     663                 :     }
     664                 :     else if (inAtom == nsDirectoryService::sInternetSearchDirectory)
     665                 :     {
     666                 :         rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile));
     667                 :     }   
     668                 :     else if (inAtom == nsDirectoryService::sUserLibDirectory)
     669                 :     {
     670                 :         rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile));
     671                 :     }
     672                 :     else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
     673                 :     {
     674                 :         rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile));
     675                 :     }
     676                 :     else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
     677                 :     {
     678                 :         // 10.5 and later, we can use kDownloadsFolderType which is defined in
     679                 :         // Folders.h as "down".  However, in order to support 10.4 still, we
     680                 :         // cannot use the named constant.  We'll use it's value, and if it
     681                 :         // fails, fall back to the desktop.
     682                 : #ifndef kDownloadsFolderType
     683                 : #define kDownloadsFolderType 'down'
     684                 : #endif
     685                 : 
     686                 :         rv = GetOSXFolderType(kUserDomain, kDownloadsFolderType,
     687                 :                               getter_AddRefs(localFile));
     688                 :         if (NS_FAILED(rv)) {
     689                 :             rv = GetOSXFolderType(kUserDomain, kDesktopFolderType,
     690                 :                                   getter_AddRefs(localFile));
     691                 :         }
     692                 :     }
     693                 :     else if (inAtom == nsDirectoryService::sUserDesktopDirectory ||
     694                 :              inAtom == nsDirectoryService::sOS_DesktopDirectory)
     695                 :     {
     696                 :         rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, getter_AddRefs(localFile));
     697                 :     }
     698                 :     else if (inAtom == nsDirectoryService::sLocalDesktopDirectory)
     699                 :     {
     700                 :         rv = GetOSXFolderType(kLocalDomain, kDesktopFolderType, getter_AddRefs(localFile));
     701                 :     }
     702                 :     else if (inAtom == nsDirectoryService::sUserApplicationsDirectory)
     703                 :     {
     704                 :         rv = GetOSXFolderType(kUserDomain, kApplicationsFolderType, getter_AddRefs(localFile));
     705                 :     }
     706                 :     else if (inAtom == nsDirectoryService::sLocalApplicationsDirectory)
     707                 :     {
     708                 :         rv = GetOSXFolderType(kLocalDomain, kApplicationsFolderType, getter_AddRefs(localFile));
     709                 :     }
     710                 :     else if (inAtom == nsDirectoryService::sUserDocumentsDirectory)
     711                 :     {
     712                 :         rv = GetOSXFolderType(kUserDomain, kDocumentsFolderType, getter_AddRefs(localFile));
     713                 :     }
     714                 :     else if (inAtom == nsDirectoryService::sLocalDocumentsDirectory)
     715                 :     {
     716                 :         rv = GetOSXFolderType(kLocalDomain, kDocumentsFolderType, getter_AddRefs(localFile));
     717                 :     }
     718                 :     else if (inAtom == nsDirectoryService::sUserInternetPlugInDirectory)
     719                 :     {
     720                 :         rv = GetOSXFolderType(kUserDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
     721                 :     }
     722                 :     else if (inAtom == nsDirectoryService::sLocalInternetPlugInDirectory)
     723                 :     {
     724                 :         rv = GetOSXFolderType(kLocalDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
     725                 :     }
     726                 :     else if (inAtom == nsDirectoryService::sUserFrameworksDirectory)
     727                 :     {
     728                 :         rv = GetOSXFolderType(kUserDomain, kFrameworksFolderType, getter_AddRefs(localFile));
     729                 :     }
     730                 :     else if (inAtom == nsDirectoryService::sLocalFrameworksDirectory)
     731                 :     {
     732                 :         rv = GetOSXFolderType(kLocalDomain, kFrameworksFolderType, getter_AddRefs(localFile));
     733                 :     }
     734                 :     else if (inAtom == nsDirectoryService::sUserPreferencesDirectory)
     735                 :     {
     736                 :         rv = GetOSXFolderType(kUserDomain, kPreferencesFolderType, getter_AddRefs(localFile));
     737                 :     }
     738                 :     else if (inAtom == nsDirectoryService::sLocalPreferencesDirectory)
     739                 :     {
     740                 :         rv = GetOSXFolderType(kLocalDomain, kPreferencesFolderType, getter_AddRefs(localFile));
     741                 :     }
     742                 :     else if (inAtom == nsDirectoryService::sPictureDocumentsDirectory)
     743                 :     {
     744                 :         rv = GetOSXFolderType(kUserDomain, kPictureDocumentsFolderType, getter_AddRefs(localFile));
     745                 :     }
     746                 :     else if (inAtom == nsDirectoryService::sMovieDocumentsDirectory)
     747                 :     {
     748                 :         rv = GetOSXFolderType(kUserDomain, kMovieDocumentsFolderType, getter_AddRefs(localFile));
     749                 :     }
     750                 :     else if (inAtom == nsDirectoryService::sMusicDocumentsDirectory)
     751                 :     {
     752                 :         rv = GetOSXFolderType(kUserDomain, kMusicDocumentsFolderType, getter_AddRefs(localFile));
     753                 :     }
     754                 :     else if (inAtom == nsDirectoryService::sInternetSitesDirectory)
     755                 :     {
     756                 :         rv = GetOSXFolderType(kUserDomain, kInternetSitesFolderType, getter_AddRefs(localFile));
     757                 :     }
     758                 : #elif defined (XP_WIN)
     759                 :     else if (inAtom == nsDirectoryService::sSystemDirectory)
     760                 :     {
     761                 :         rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile)); 
     762                 :     }
     763                 :     else if (inAtom == nsDirectoryService::sWindowsDirectory)
     764                 :     {
     765                 :         rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile)); 
     766                 :     }
     767                 :     else if (inAtom == nsDirectoryService::sWindowsProgramFiles)
     768                 :     {
     769                 :         rv = GetSpecialSystemDirectory(Win_ProgramFiles, getter_AddRefs(localFile));
     770                 :     }
     771                 :     else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
     772                 :     {
     773                 :         rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile)); 
     774                 :     }
     775                 :     else if (inAtom == nsDirectoryService::sDesktop)
     776                 :     {
     777                 :         rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile)); 
     778                 :     }
     779                 :     else if (inAtom == nsDirectoryService::sPrograms)
     780                 :     {
     781                 :         rv = GetSpecialSystemDirectory(Win_Programs, getter_AddRefs(localFile)); 
     782                 :     }
     783                 :     else if (inAtom == nsDirectoryService::sControls)
     784                 :     {
     785                 :         rv = GetSpecialSystemDirectory(Win_Controls, getter_AddRefs(localFile)); 
     786                 :     }
     787                 :     else if (inAtom == nsDirectoryService::sPrinters)
     788                 :     {
     789                 :         rv = GetSpecialSystemDirectory(Win_Printers, getter_AddRefs(localFile)); 
     790                 :     }
     791                 :     else if (inAtom == nsDirectoryService::sPersonal)
     792                 :     {
     793                 :         rv = GetSpecialSystemDirectory(Win_Personal, getter_AddRefs(localFile)); 
     794                 :     }
     795                 :     else if (inAtom == nsDirectoryService::sFavorites)
     796                 :     {
     797                 :         rv = GetSpecialSystemDirectory(Win_Favorites, getter_AddRefs(localFile)); 
     798                 :     }
     799                 :     else if (inAtom == nsDirectoryService::sStartup)
     800                 :     {
     801                 :         rv = GetSpecialSystemDirectory(Win_Startup, getter_AddRefs(localFile));
     802                 :     }
     803                 :     else if (inAtom == nsDirectoryService::sRecent)
     804                 :     {
     805                 :         rv = GetSpecialSystemDirectory(Win_Recent, getter_AddRefs(localFile)); 
     806                 :     }
     807                 :     else if (inAtom == nsDirectoryService::sSendto)
     808                 :     {
     809                 :         rv = GetSpecialSystemDirectory(Win_Sendto, getter_AddRefs(localFile)); 
     810                 :     }
     811                 :     else if (inAtom == nsDirectoryService::sBitbucket)
     812                 :     {
     813                 :         rv = GetSpecialSystemDirectory(Win_Bitbucket, getter_AddRefs(localFile)); 
     814                 :     }
     815                 :     else if (inAtom == nsDirectoryService::sStartmenu)
     816                 :     {
     817                 :         rv = GetSpecialSystemDirectory(Win_Startmenu, getter_AddRefs(localFile)); 
     818                 :     }
     819                 :     else if (inAtom == nsDirectoryService::sDesktopdirectory ||
     820                 :              inAtom == nsDirectoryService::sOS_DesktopDirectory)
     821                 :     {
     822                 :         rv = GetSpecialSystemDirectory(Win_Desktopdirectory, getter_AddRefs(localFile)); 
     823                 :     }
     824                 :     else if (inAtom == nsDirectoryService::sDrives)
     825                 :     {
     826                 :         rv = GetSpecialSystemDirectory(Win_Drives, getter_AddRefs(localFile));
     827                 :     }
     828                 :     else if (inAtom == nsDirectoryService::sNetwork)
     829                 :     {
     830                 :         rv = GetSpecialSystemDirectory(Win_Network, getter_AddRefs(localFile)); 
     831                 :     }
     832                 :     else if (inAtom == nsDirectoryService::sNethood)
     833                 :     {
     834                 :         rv = GetSpecialSystemDirectory(Win_Nethood, getter_AddRefs(localFile)); 
     835                 :     }
     836                 :     else if (inAtom == nsDirectoryService::sFonts)
     837                 :     {
     838                 :         rv = GetSpecialSystemDirectory(Win_Fonts, getter_AddRefs(localFile));
     839                 :     }
     840                 :     else if (inAtom == nsDirectoryService::sTemplates)
     841                 :     {
     842                 :         rv = GetSpecialSystemDirectory(Win_Templates, getter_AddRefs(localFile)); 
     843                 :     }
     844                 :     else if (inAtom == nsDirectoryService::sCommon_Startmenu)
     845                 :     {
     846                 :         rv = GetSpecialSystemDirectory(Win_Common_Startmenu, getter_AddRefs(localFile)); 
     847                 :     }
     848                 :     else if (inAtom == nsDirectoryService::sCommon_Programs)
     849                 :     {
     850                 :         rv = GetSpecialSystemDirectory(Win_Common_Programs, getter_AddRefs(localFile)); 
     851                 :     }
     852                 :     else if (inAtom == nsDirectoryService::sCommon_Startup)
     853                 :     {
     854                 :         rv = GetSpecialSystemDirectory(Win_Common_Startup, getter_AddRefs(localFile)); 
     855                 :     }
     856                 :     else if (inAtom == nsDirectoryService::sCommon_Desktopdirectory)
     857                 :     {
     858                 :         rv = GetSpecialSystemDirectory(Win_Common_Desktopdirectory, getter_AddRefs(localFile)); 
     859                 :     }
     860                 :     else if (inAtom == nsDirectoryService::sCommon_AppData)
     861                 :     {
     862                 :         rv = GetSpecialSystemDirectory(Win_Common_AppData, getter_AddRefs(localFile)); 
     863                 :     }
     864                 :     else if (inAtom == nsDirectoryService::sAppdata)
     865                 :     {
     866                 :         rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile)); 
     867                 :     }
     868                 :     else if (inAtom == nsDirectoryService::sLocalAppdata)
     869                 :     {
     870                 :         rv = GetSpecialSystemDirectory(Win_LocalAppdata, getter_AddRefs(localFile)); 
     871                 :     }
     872                 :     else if (inAtom == nsDirectoryService::sPrinthood)
     873                 :     {
     874                 :         rv = GetSpecialSystemDirectory(Win_Printhood, getter_AddRefs(localFile)); 
     875                 :     }
     876                 :     else if (inAtom == nsDirectoryService::sWinCookiesDirectory)
     877                 :     {
     878                 :         rv = GetSpecialSystemDirectory(Win_Cookies, getter_AddRefs(localFile)); 
     879                 :     }
     880                 :     else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
     881                 :     {
     882                 :         rv = GetSpecialSystemDirectory(Win_Downloads, getter_AddRefs(localFile));
     883                 :     }
     884                 : #elif defined (XP_UNIX)
     885                 : 
     886            7448 :     else if (inAtom == nsDirectoryService::sLocalDirectory)
     887                 :     {
     888               0 :         rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile)); 
     889                 :     }
     890            7448 :     else if (inAtom == nsDirectoryService::sLibDirectory)
     891                 :     {
     892               0 :         rv = GetSpecialSystemDirectory(Unix_LibDirectory, getter_AddRefs(localFile));
     893                 :     }
     894            7448 :     else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
     895                 :     {
     896              31 :         rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile)); 
     897                 :     }
     898           14834 :     else if (inAtom == nsDirectoryService::sXDGDesktop ||
     899            7417 :              inAtom == nsDirectoryService::sOS_DesktopDirectory)
     900                 :     {
     901               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Desktop, getter_AddRefs(localFile));
     902               0 :         *persistent = false;
     903                 :     }
     904            7417 :     else if (inAtom == nsDirectoryService::sXDGDocuments)
     905                 :     {
     906               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Documents, getter_AddRefs(localFile));
     907               0 :         *persistent = false;
     908                 :     }
     909           14834 :     else if (inAtom == nsDirectoryService::sXDGDownload ||
     910            7417 :              inAtom == nsDirectoryService::sDefaultDownloadDirectory)
     911                 :     {
     912               9 :         rv = GetSpecialSystemDirectory(Unix_XDG_Download, getter_AddRefs(localFile));
     913               9 :         *persistent = false;
     914                 :     }
     915            7408 :     else if (inAtom == nsDirectoryService::sXDGMusic)
     916                 :     {
     917               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Music, getter_AddRefs(localFile));
     918               0 :         *persistent = false;
     919                 :     }
     920            7408 :     else if (inAtom == nsDirectoryService::sXDGPictures)
     921                 :     {
     922               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Pictures, getter_AddRefs(localFile));
     923               0 :         *persistent = false;
     924                 :     }
     925            7408 :     else if (inAtom == nsDirectoryService::sXDGPublicShare)
     926                 :     {
     927               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_PublicShare, getter_AddRefs(localFile));
     928               0 :         *persistent = false;
     929                 :     }
     930            7408 :     else if (inAtom == nsDirectoryService::sXDGTemplates)
     931                 :     {
     932               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Templates, getter_AddRefs(localFile));
     933               0 :         *persistent = false;
     934                 :     }
     935            7408 :     else if (inAtom == nsDirectoryService::sXDGVideos)
     936                 :     {
     937               0 :         rv = GetSpecialSystemDirectory(Unix_XDG_Videos, getter_AddRefs(localFile));
     938               0 :         *persistent = false;
     939                 :     }
     940                 : #elif defined (XP_OS2)
     941                 :     else if (inAtom == nsDirectoryService::sSystemDirectory)
     942                 :     {
     943                 :         rv = GetSpecialSystemDirectory(OS2_SystemDirectory, getter_AddRefs(localFile)); 
     944                 :     }
     945                 :     else if (inAtom == nsDirectoryService::sOS2Directory)
     946                 :     {
     947                 :         rv = GetSpecialSystemDirectory(OS2_OS2Directory, getter_AddRefs(localFile)); 
     948                 :     }
     949                 :     else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
     950                 :     {
     951                 :         rv = GetSpecialSystemDirectory(OS2_HomeDirectory, getter_AddRefs(localFile)); 
     952                 :     }
     953                 :     else if (inAtom == nsDirectoryService::sOS_DesktopDirectory)
     954                 :     {
     955                 :         rv = GetSpecialSystemDirectory(OS2_DesktopDirectory, getter_AddRefs(localFile)); 
     956                 :     }
     957                 : #endif
     958                 : 
     959           11234 :     if (NS_FAILED(rv))
     960            7417 :         return rv;
     961                 : 
     962            3817 :     if (!localFile)
     963               0 :         return NS_ERROR_FAILURE;
     964                 : 
     965            3817 :     return CallQueryInterface(localFile, _retval);
     966                 : }
     967                 : 
     968                 : NS_IMETHODIMP
     969            1456 : nsDirectoryService::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
     970                 : {
     971            1456 :     NS_ENSURE_ARG_POINTER(_retval);
     972            1456 :     *_retval = nsnull;
     973                 :         
     974            1456 :     return NS_ERROR_FAILURE;
     975                 : }

Generated by: LCOV version 1.7