1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is Mozilla Communicator client code, released
18
* The Initial Developer of the Original Code is
19
* Netscape Communications Corporation.
20
* Portions created by the Initial Developer are Copyright (C) 2000
21
* the Initial Developer. All Rights Reserved.
24
* Conrad Carlen <conrad@ingress.com>
26
* Alternatively, the contents of this file may be used under the terms of
27
* either of the GNU General Public License Version 2 or later (the "GPL"),
28
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the MPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the MPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
40
#include "nsAppFileLocationProvider.h"
41
#include "nsAppDirectoryServiceDefs.h"
42
#include "nsDirectoryServiceDefs.h"
44
#include "nsILocalFile.h"
46
#include "nsXPIDLString.h"
47
#include "nsISimpleEnumerator.h"
51
#if defined(XP_MAC) || defined(XP_MACOSX)
54
#include <Processes.h>
56
#include "nsILocalFileMac.h"
58
#define INCL_DOSPROCESS
59
#define INCL_DOSMODULEMGR
64
#elif defined(XP_UNIX)
67
#include <sys/param.h>
68
#elif defined(XP_BEOS)
69
#include <sys/param.h>
70
#include <kernel/image.h>
71
#include <storage/FindDirectory.h>
75
// WARNING: These hard coded names need to go away. They need to
76
// come from localizable resources
78
#if defined(XP_MAC) || defined(XP_MACOSX)
79
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("Application Registry")
80
#define ESSENTIAL_FILES NS_LITERAL_CSTRING("Essential Files")
81
#elif defined(XP_WIN) || defined(XP_OS2)
82
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat")
84
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("appreg")
87
// define default product directory
89
#define DEFAULT_PRODUCT_DIR NS_LITERAL_CSTRING("Mozilla")
91
#define DEFAULT_PRODUCT_DIR NS_LITERAL_CSTRING(MOZ_USER_DIR)
94
// Locally defined keys used by nsAppDirectoryEnumerator
95
#define NS_ENV_PLUGINS_DIR "EnvPlugins" // env var MOZ_PLUGIN_PATH
96
#define NS_USER_PLUGINS_DIR "UserPlugins"
98
#if defined(XP_MAC) || defined(XP_MACOSX)
99
#define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins"
100
#define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins"
101
#define NS_MAC_CLASSIC_PLUGIN_DIR "MacSysPlugins"
105
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("Defaults")
106
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("Pref")
107
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("Profile")
108
#define RES_DIR_NAME NS_LITERAL_CSTRING("Res")
109
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("Chrome")
110
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("Plug-ins")
111
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("Search Plugins")
113
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults")
114
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref")
115
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("profile")
116
#define RES_DIR_NAME NS_LITERAL_CSTRING("res")
117
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome")
118
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins")
119
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins")
122
//*****************************************************************************
123
// nsAppFileLocationProvider::Constructor/Destructor
124
//*****************************************************************************
126
nsAppFileLocationProvider::nsAppFileLocationProvider()
130
//*****************************************************************************
131
// nsAppFileLocationProvider::nsISupports
132
//*****************************************************************************
134
NS_IMPL_THREADSAFE_ISUPPORTS2(nsAppFileLocationProvider, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
136
//*****************************************************************************
137
// nsAppFileLocationProvider::nsIDirectoryServiceProvider
138
//*****************************************************************************
141
nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
143
nsCOMPtr<nsILocalFile> localFile;
144
nsresult rv = NS_ERROR_FAILURE;
148
*persistant = PR_TRUE;
150
#if defined (XP_MAC) || defined(XP_MACOSX)
154
nsCOMPtr<nsILocalFileMac> macFile;
157
if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
159
rv = GetProductDirectory(getter_AddRefs(localFile));
161
else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0)
163
rv = GetProductDirectory(getter_AddRefs(localFile));
164
if (NS_SUCCEEDED(rv))
165
rv = localFile->AppendNative(APP_REGISTRY_NAME);
167
else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
169
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
170
if (NS_SUCCEEDED(rv))
171
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
173
else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
175
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
176
if (NS_SUCCEEDED(rv)) {
177
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
178
if (NS_SUCCEEDED(rv))
179
rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
182
else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 ||
183
nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0)
185
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
186
if (NS_SUCCEEDED(rv)) {
187
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
188
if (NS_SUCCEEDED(rv))
189
rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME);
192
else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
194
rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
196
else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0)
198
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
199
if (NS_SUCCEEDED(rv))
200
rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
202
else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
204
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
205
if (NS_SUCCEEDED(rv))
206
rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
208
else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
210
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
211
if (NS_SUCCEEDED(rv))
212
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
214
#if defined(XP_MAC) || defined(XP_MACOSX)
215
else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
217
if (!(::FindFolder(kUserDomain,
218
kInternetPlugInFolderType,
219
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
220
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
221
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
222
if (NS_SUCCEEDED(rv))
226
else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
228
if (!(::FindFolder(kLocalDomain,
229
kInternetPlugInFolderType,
230
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
231
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
232
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
233
if (NS_SUCCEEDED(rv))
237
else if (nsCRT::strcmp(prop, NS_MAC_CLASSIC_PLUGIN_DIR) == 0)
239
if (!(::FindFolder(kOnAppropriateDisk,
240
kInternetPlugInFolderType,
241
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
242
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
243
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
244
if (NS_SUCCEEDED(rv))
249
else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
251
NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). "
252
"Use nsAppFileLocationProvider::GetFiles(...).");
253
const char *pathVar = PR_GetEnv("VBOX_XPCOM_PLUGIN_PATH");
255
rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), PR_TRUE, getter_AddRefs(localFile));
257
else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0)
259
rv = GetProductDirectory(getter_AddRefs(localFile));
260
if (NS_SUCCEEDED(rv))
261
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
264
else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
266
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
267
if (NS_SUCCEEDED(rv))
268
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
270
else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
272
// This is cloned so that embeddors will have a hook to override
273
// with their own cleanup dir. See bugzilla bug #105087
274
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
276
if (NS_SUCCEEDED(rv))
277
rv = localFile->AppendNative(ESSENTIAL_FILES);
282
if (localFile && NS_SUCCEEDED(rv))
283
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
289
NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsILocalFile **aLocalFile)
291
NS_ENSURE_ARG_POINTER(aLocalFile);
294
if (!mMozBinDirectory)
296
// Get the mozilla bin directory
297
// 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
298
// This will be set if a directory was passed to NS_InitXPCOM
299
// 2. If that doesn't work, set it to be the current process directory
300
nsCOMPtr<nsIProperties>
301
directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
305
rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
307
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
313
nsCOMPtr<nsIFile> aFile;
314
rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
318
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface (aFile);
320
return NS_ERROR_FAILURE;
322
NS_IF_ADDREF(*aLocalFile = lfile);
327
//----------------------------------------------------------------------------------------
328
// GetProductDirectory - Gets the directory which contains the application data folder
330
// UNIX : ~/.mozilla/
331
// WIN : <Application Data folder on user's machine>\Mozilla
332
// Mac : :Documents:Mozilla:
333
//----------------------------------------------------------------------------------------
334
NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFile)
336
NS_ENSURE_ARG_POINTER(aLocalFile);
340
nsCOMPtr<nsILocalFile> localDir;
343
nsCOMPtr<nsIProperties> directoryService =
344
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
345
if (NS_FAILED(rv)) return rv;
348
err = ::Gestalt(gestaltSystemVersion, &response);
349
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
350
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
351
if (NS_FAILED(rv)) return rv;
352
#elif defined(XP_MACOSX)
354
OSErr err = ::FSFindFolder(kUserDomain, kDomainLibraryFolderType, kCreateFolder, &fsRef);
355
if (err) return NS_ERROR_FAILURE;
356
NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir));
357
if (!localDir) return NS_ERROR_FAILURE;
358
nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
359
rv = localDirMac->InitWithFSRef(&fsRef);
360
if (NS_FAILED(rv)) return rv;
361
#elif defined(XP_OS2)
362
nsCOMPtr<nsIProperties> directoryService =
363
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
364
if (NS_FAILED(rv)) return rv;
365
rv = directoryService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
366
if (NS_FAILED(rv)) return rv;
367
#elif defined(XP_WIN)
368
nsCOMPtr<nsIProperties> directoryService =
369
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
370
if (NS_FAILED(rv)) return rv;
371
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
372
if (NS_SUCCEEDED(rv))
373
rv = localDir->Exists(&exists);
374
if (NS_FAILED(rv) || !exists)
376
// On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
378
rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
380
if (NS_FAILED(rv)) return rv;
382
/* Major hack attack, should sort out the environment stuff!!! */
383
rv = NS_NewNativeLocalFile(nsDependentCString("."), PR_TRUE, getter_AddRefs(localDir));
384
if (NS_FAILED(rv)) return rv;
385
#elif defined(XP_UNIX)
386
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_TRUE, getter_AddRefs(localDir));
387
if (NS_FAILED(rv)) return rv;
388
#elif defined(XP_BEOS)
389
char path[MAXPATHLEN];
390
find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
391
// Need enough space to add the trailing backslash
392
int len = strlen(path);
393
if (len > MAXPATHLEN-2)
394
return NS_ERROR_FAILURE;
397
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localDir));
398
if (NS_FAILED(rv)) return rv;
400
#error dont_know_how_to_get_product_dir_on_your_platform
403
rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
404
if (NS_FAILED(rv)) return rv;
405
rv = localDir->Exists(&exists);
406
if (NS_SUCCEEDED(rv) && !exists)
407
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
408
if (NS_FAILED(rv)) return rv;
410
*aLocalFile = localDir;
411
NS_ADDREF(*aLocalFile);
417
//----------------------------------------------------------------------------------------
418
// GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
420
// UNIX : ~/.mozilla/
421
// WIN : <Application Data folder on user's machine>\Mozilla\Profiles
422
// Mac : :Documents:Mozilla:Profiles:
423
//----------------------------------------------------------------------------------------
424
NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aLocalFile)
426
NS_ENSURE_ARG_POINTER(aLocalFile);
429
nsCOMPtr<nsILocalFile> localDir;
431
rv = GetProductDirectory(getter_AddRefs(localDir));
432
if (NS_FAILED(rv)) return rv;
434
#if defined(XP_MAC) || defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_WIN)
435
// These 3 platforms share this part of the path - do them as one
436
rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
437
if (NS_FAILED(rv)) return rv;
440
rv = localDir->Exists(&exists);
441
if (NS_SUCCEEDED(rv) && !exists)
442
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
443
if (NS_FAILED(rv)) return rv;
446
*aLocalFile = localDir;
447
NS_ADDREF(*aLocalFile);
452
//*****************************************************************************
453
// nsAppFileLocationProvider::nsIDirectoryServiceProvider2
454
//*****************************************************************************
456
class nsAppDirectoryEnumerator : public nsISimpleEnumerator
462
* aKeyList is a null-terminated list of properties which are provided by aProvider
463
* They do not need to be publicly defined keys.
465
nsAppDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
466
const char* aKeyList[]) :
467
mProvider(aProvider),
468
mCurrentKey(aKeyList)
472
NS_IMETHOD HasMoreElements(PRBool *result)
474
while (!mNext && *mCurrentKey)
477
nsCOMPtr<nsIFile> testFile;
478
(void)mProvider->GetFile(*mCurrentKey++, &dontCare, getter_AddRefs(testFile));
479
// Don't return a file which does not exist.
481
if (testFile && NS_SUCCEEDED(testFile->Exists(&exists)) && exists)
484
*result = mNext != nsnull;
488
NS_IMETHOD GetNext(nsISupports **result)
490
NS_ENSURE_ARG_POINTER(result);
494
HasMoreElements(&hasMore);
496
return NS_ERROR_FAILURE;
499
NS_IF_ADDREF(*result);
502
return *result ? NS_OK : NS_ERROR_FAILURE;
505
// Virtual destructor since subclass nsPathsDirectoryEnumerator
506
// does not re-implement Release()
508
virtual ~nsAppDirectoryEnumerator()
513
nsIDirectoryServiceProvider *mProvider;
514
const char** mCurrentKey;
515
nsCOMPtr<nsIFile> mNext;
518
NS_IMPL_ISUPPORTS1(nsAppDirectoryEnumerator, nsISimpleEnumerator)
520
/* nsPathsDirectoryEnumerator and PATH_SEPARATOR
521
* are not used on MacOS/X. */
523
#if defined(XP_WIN) || defined(XP_OS2)/* Win32, Win16, and OS/2 */
524
#define PATH_SEPARATOR ';'
525
#else /*if defined(XP_UNIX) || defined(XP_BEOS)*/
526
#define PATH_SEPARATOR ':'
529
class nsPathsDirectoryEnumerator : public nsAppDirectoryEnumerator
533
* aKeyList is a null-terminated list.
534
* The first element is a path list.
535
* The remainder are properties provided by aProvider.
536
* They do not need to be publicly defined keys.
538
nsPathsDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
539
const char* aKeyList[]) :
540
nsAppDirectoryEnumerator(aProvider, aKeyList+1),
541
mEndPath(aKeyList[0])
545
NS_IMETHOD HasMoreElements(PRBool *result)
548
while (!mNext && *mEndPath)
550
const char *pathVar = mEndPath;
551
do { ++mEndPath; } while (*mEndPath && *mEndPath != PATH_SEPARATOR);
553
nsCOMPtr<nsILocalFile> localFile;
554
NS_NewNativeLocalFile(Substring(pathVar, mEndPath),
556
getter_AddRefs(localFile));
557
if (*mEndPath == PATH_SEPARATOR)
559
// Don't return a "file" (directory) which does not exist.
562
NS_SUCCEEDED(localFile->Exists(&exists)) &&
569
nsAppDirectoryEnumerator::HasMoreElements(result);
575
const char *mEndPath;
579
nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
581
NS_ENSURE_ARG_POINTER(_retval);
583
nsresult rv = NS_ERROR_FAILURE;
585
if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
587
#if defined(XP_MAC) || defined(XP_MACOSX)
588
static const char* osXKeys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull };
589
static const char* os9Keys[] = { NS_APP_PLUGINS_DIR, NS_MAC_CLASSIC_PLUGIN_DIR, nsnull };
590
static const char** keys;
595
err = ::Gestalt(gestaltSystemVersion, &response);
596
keys = (!err && response >= 0x00001000) ? osXKeys : os9Keys;
599
*_retval = new nsAppDirectoryEnumerator(this, keys);
601
static const char* keys[] = { nsnull, NS_APP_PLUGINS_DIR, nsnull };
602
if (!keys[0] && !(keys[0] = PR_GetEnv("VBOX_XPCOM_PLUGIN_PATH"))) {
603
static const char nullstr = 0;
606
*_retval = new nsPathsDirectoryEnumerator(this, keys);
608
NS_IF_ADDREF(*_retval);
609
rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;