2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-09 14:00:48 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
#include "fcntl.h"
|
|
|
|
#include "errno.h"
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
#include "prsystem.h"
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
#if defined(XP_UNIX)
|
|
|
|
#include "unistd.h"
|
2012-07-05 12:20:38 +04:00
|
|
|
#include "dirent.h"
|
2016-05-09 06:34:48 +03:00
|
|
|
#include "poll.h"
|
2012-07-21 21:46:03 +04:00
|
|
|
#include "sys/stat.h"
|
2014-03-30 22:25:00 +04:00
|
|
|
#if defined(XP_LINUX)
|
2014-01-15 11:04:00 +04:00
|
|
|
#include <sys/vfs.h>
|
|
|
|
#define statvfs statfs
|
2014-03-30 22:25:00 +04:00
|
|
|
#define f_frsize f_bsize
|
2014-01-15 11:04:00 +04:00
|
|
|
#else
|
|
|
|
#include "sys/statvfs.h"
|
2014-03-30 22:25:00 +04:00
|
|
|
#endif // defined(XP_LINUX)
|
|
|
|
#if !defined(ANDROID)
|
2016-05-09 06:34:48 +03:00
|
|
|
#include "sys/wait.h"
|
2013-11-18 22:04:33 +04:00
|
|
|
#include <spawn.h>
|
2014-03-30 22:25:00 +04:00
|
|
|
#endif // !defined(ANDROID)
|
2012-05-09 14:00:48 +04:00
|
|
|
#endif // defined(XP_UNIX)
|
|
|
|
|
2013-10-11 21:43:48 +04:00
|
|
|
#if defined(XP_LINUX)
|
|
|
|
#include <linux/fadvise.h>
|
|
|
|
#endif // defined(XP_LINUX)
|
|
|
|
|
2012-06-17 19:49:30 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2012-06-15 19:22:31 +04:00
|
|
|
#include "copyfile.h"
|
2012-06-17 19:49:30 +04:00
|
|
|
#endif // defined(XP_MACOSX)
|
2012-06-15 19:22:31 +04:00
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
#include <windows.h>
|
2014-01-22 21:33:48 +04:00
|
|
|
#include <accctrl.h>
|
2014-05-05 14:53:00 +04:00
|
|
|
|
2017-10-18 02:46:22 +03:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX MAX_PATH
|
|
|
|
#endif
|
2014-05-05 14:53:00 +04:00
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
#endif // defined(XP_WIN)
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
#include "jsapi.h"
|
|
|
|
#include "jsfriendapi.h"
|
|
|
|
#include "BindingUtils.h"
|
2012-06-21 23:58:25 +04:00
|
|
|
|
|
|
|
// Used to provide information on the OS
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2012-12-12 03:12:59 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIObserver.h"
|
2012-06-29 05:56:30 +04:00
|
|
|
#include "nsDirectoryServiceUtils.h"
|
2012-06-21 23:58:25 +04:00
|
|
|
#include "nsIXULRuntime.h"
|
2014-04-26 18:56:58 +04:00
|
|
|
#include "nsIPropertyBag2.h"
|
2012-06-21 23:58:25 +04:00
|
|
|
#include "nsXPCOMCIDInternal.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsString.h"
|
2017-05-03 11:45:15 +03:00
|
|
|
#include "nsSystemInfo.h"
|
2012-08-23 00:58:08 +04:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2014-01-13 17:45:20 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2012-08-23 00:58:08 +04:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
2012-11-26 20:55:12 +04:00
|
|
|
#include "mozJSComponentLoader.h"
|
2012-06-21 23:58:25 +04:00
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
2017-11-10 21:37:13 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-11-10 21:27:03 +03:00
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
#include "OSFileConstants.h"
|
2012-07-04 16:30:58 +04:00
|
|
|
#include "nsIOSFileConstantsService.h"
|
2013-09-10 01:14:10 +04:00
|
|
|
#include "nsZipArchive.h"
|
2012-05-09 14:00:48 +04:00
|
|
|
|
2012-12-02 06:25:24 +04:00
|
|
|
#if defined(__DragonFly__) || defined(__FreeBSD__) \
|
|
|
|
|| defined(__NetBSD__) || defined(__OpenBSD__)
|
|
|
|
#define __dd_fd dd_fd
|
|
|
|
#endif
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
/**
|
|
|
|
* This module defines the basic libc constants (error numbers, open modes,
|
|
|
|
* etc.) used by OS.File and possibly other OS-bound JavaScript libraries.
|
|
|
|
*/
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
namespace {
|
2017-11-10 21:27:03 +03:00
|
|
|
|
|
|
|
StaticRefPtr<OSFileConstantsService> gInstance;
|
2012-06-29 05:56:30 +04:00
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
struct
|
|
|
|
OSFileConstantsService::Paths
|
|
|
|
{
|
2012-08-23 00:58:08 +04:00
|
|
|
/**
|
|
|
|
* The name of the directory holding all the libraries (libxpcom, libnss, etc.)
|
|
|
|
*/
|
|
|
|
nsString libDir;
|
|
|
|
nsString tmpDir;
|
|
|
|
nsString profileDir;
|
2012-12-02 06:20:44 +04:00
|
|
|
nsString localProfileDir;
|
2013-09-30 18:59:41 +04:00
|
|
|
/**
|
|
|
|
* The user's home directory
|
|
|
|
*/
|
|
|
|
nsString homeDir;
|
2014-01-13 17:45:20 +04:00
|
|
|
/**
|
|
|
|
* The user's 'application data' directory.
|
|
|
|
* Windows:
|
|
|
|
* HOME = Documents and Settings\$USER\Application Data
|
|
|
|
* UAppData = $HOME[\$vendor]\$name
|
|
|
|
*
|
|
|
|
* Unix:
|
|
|
|
* HOME = ~
|
|
|
|
* UAppData = $HOME/.[$vendor/]$name
|
|
|
|
*
|
|
|
|
* Mac:
|
|
|
|
* HOME = ~
|
|
|
|
* UAppData = $HOME/Library/Application Support/$name
|
|
|
|
*/
|
|
|
|
nsString userApplicationDataDir;
|
2013-09-30 18:59:41 +04:00
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
/**
|
|
|
|
* The user's Library directory.
|
|
|
|
*/
|
|
|
|
nsString macUserLibDir;
|
|
|
|
#endif // defined(XP_MACOSX)
|
2012-12-17 04:36:27 +04:00
|
|
|
|
|
|
|
Paths()
|
|
|
|
{
|
|
|
|
libDir.SetIsVoid(true);
|
|
|
|
tmpDir.SetIsVoid(true);
|
|
|
|
profileDir.SetIsVoid(true);
|
|
|
|
localProfileDir.SetIsVoid(true);
|
2013-09-30 18:59:41 +04:00
|
|
|
homeDir.SetIsVoid(true);
|
2014-01-13 17:45:20 +04:00
|
|
|
userApplicationDataDir.SetIsVoid(true);
|
2013-09-30 18:59:41 +04:00
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
macUserLibDir.SetIsVoid(true);
|
|
|
|
#endif // defined(XP_MACOSX)
|
2012-12-17 04:36:27 +04:00
|
|
|
}
|
|
|
|
};
|
2012-08-23 00:58:08 +04:00
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
/**
|
2012-08-23 00:58:08 +04:00
|
|
|
* Return the path to one of the special directories.
|
2012-08-23 00:58:09 +04:00
|
|
|
*
|
|
|
|
* @param aKey The key to the special directory (e.g. "TmpD", "ProfD", ...)
|
|
|
|
* @param aOutPath The path to the special directory. In case of error,
|
|
|
|
* the string is set to void.
|
2012-06-29 05:56:30 +04:00
|
|
|
*/
|
2012-08-23 00:58:08 +04:00
|
|
|
nsresult GetPathToSpecialDir(const char *aKey, nsString& aOutPath)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFile> file;
|
|
|
|
nsresult rv = NS_GetSpecialDirectory(aKey, getter_AddRefs(file));
|
|
|
|
if (NS_FAILED(rv) || !file) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-12-17 04:36:27 +04:00
|
|
|
return file->GetPath(aOutPath);
|
2012-06-29 05:56:30 +04:00
|
|
|
}
|
|
|
|
|
2012-12-12 03:12:59 +04:00
|
|
|
/**
|
|
|
|
* In some cases, OSFileConstants may be instantiated before the
|
|
|
|
* profile is setup. In such cases, |OS.Constants.Path.profileDir| and
|
|
|
|
* |OS.Constants.Path.localProfileDir| are undefined. However, we want
|
|
|
|
* to ensure that this does not break existing code, so that future
|
|
|
|
* workers spawned after the profile is setup have these constants.
|
|
|
|
*
|
2017-11-10 21:27:29 +03:00
|
|
|
* For this purpose, we register an observer to set |mPaths->profileDir|
|
|
|
|
* and |mPaths->localProfileDir| once the profile is setup.
|
2012-12-12 03:12:59 +04:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2017-11-10 21:27:29 +03:00
|
|
|
OSFileConstantsService::Observe(nsISupports*,
|
|
|
|
const char* aTopic,
|
|
|
|
const char16_t*)
|
2012-12-12 03:12:59 +04:00
|
|
|
{
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!mInitialized) {
|
|
|
|
// Initialization has not taken place, something is wrong,
|
2012-12-12 03:12:59 +04:00
|
|
|
// don't make things worse.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-11-10 21:27:55 +03:00
|
|
|
|
|
|
|
nsresult rv = GetPathToSpecialDir(NS_APP_USER_PROFILE_50_DIR, mPaths->profileDir);
|
2012-12-12 03:12:59 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2017-11-10 21:27:55 +03:00
|
|
|
rv = GetPathToSpecialDir(NS_APP_USER_PROFILE_LOCAL_50_DIR, mPaths->localProfileDir);
|
2012-12-12 03:12:59 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
/**
|
|
|
|
* Perform the part of initialization that can only be
|
|
|
|
* executed on the main thread.
|
|
|
|
*/
|
2017-11-10 21:27:03 +03:00
|
|
|
nsresult
|
|
|
|
OSFileConstantsService::InitOSFileConstants()
|
2012-06-29 05:56:30 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-11-10 21:27:03 +03:00
|
|
|
if (mInitialized) {
|
2012-07-04 16:30:58 +04:00
|
|
|
return NS_OK;
|
2012-06-29 05:56:30 +04:00
|
|
|
}
|
|
|
|
|
2017-11-10 21:37:13 +03:00
|
|
|
UniquePtr<Paths> paths(new Paths);
|
2012-08-23 00:58:08 +04:00
|
|
|
|
|
|
|
// Initialize paths->libDir
|
|
|
|
nsCOMPtr<nsIFile> file;
|
2014-01-13 17:45:20 +04:00
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_XPCOM_LIBRARY_FILE, getter_AddRefs(file));
|
2012-08-23 00:58:08 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-29 05:56:30 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> libDir;
|
2012-08-23 00:58:08 +04:00
|
|
|
rv = file->GetParent(getter_AddRefs(libDir));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = libDir->GetPath(paths->libDir);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-12-12 03:12:59 +04:00
|
|
|
// Setup profileDir and localProfileDir immediately if possible (we
|
|
|
|
// assume that NS_APP_USER_PROFILE_50_DIR and
|
|
|
|
// NS_APP_USER_PROFILE_LOCAL_50_DIR are set simultaneously)
|
|
|
|
rv = GetPathToSpecialDir(NS_APP_USER_PROFILE_50_DIR, paths->profileDir);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = GetPathToSpecialDir(NS_APP_USER_PROFILE_LOCAL_50_DIR, paths->localProfileDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, delay setup of profileDir/localProfileDir until they
|
|
|
|
// become available.
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
nsCOMPtr<nsIObserverService> obsService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2017-11-10 21:27:29 +03:00
|
|
|
rv = obsService->AddObserver(this, "profile-do-change", false);
|
2012-12-12 03:12:59 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 00:58:09 +04:00
|
|
|
// For other directories, ignore errors (they may be undefined on
|
|
|
|
// some platforms or in non-Firefox embeddings of Gecko).
|
2012-08-23 00:58:08 +04:00
|
|
|
|
2012-08-23 00:58:09 +04:00
|
|
|
GetPathToSpecialDir(NS_OS_TEMP_DIR, paths->tmpDir);
|
2013-09-30 18:59:41 +04:00
|
|
|
GetPathToSpecialDir(NS_OS_HOME_DIR, paths->homeDir);
|
2014-01-13 17:45:20 +04:00
|
|
|
GetPathToSpecialDir(XRE_USER_APP_DATA_DIR, paths->userApplicationDataDir);
|
2013-09-30 18:59:41 +04:00
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
GetPathToSpecialDir(NS_MAC_USER_LIB_DIR, paths->macUserLibDir);
|
|
|
|
#endif // defined(XP_MACOSX)
|
2012-06-29 05:56:30 +04:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
mPaths = std::move(paths);
|
2014-04-26 18:56:58 +04:00
|
|
|
|
|
|
|
// Get the umask from the system-info service.
|
|
|
|
// The property will always be present, but it will be zero on
|
|
|
|
// non-Unix systems.
|
2017-05-03 11:45:15 +03:00
|
|
|
// nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM2 so we don't need
|
|
|
|
// to initialize the service.
|
2017-11-10 21:27:55 +03:00
|
|
|
mUserUmask = nsSystemInfo::gUserUmask;
|
2014-04-26 18:56:58 +04:00
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
mInitialized = true;
|
2012-08-23 00:58:08 +04:00
|
|
|
return NS_OK;
|
2012-06-29 05:56:30 +04:00
|
|
|
}
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
/**
|
|
|
|
* Define a simple read-only property holding an integer.
|
|
|
|
*
|
|
|
|
* @param name The name of the constant. Used both as the JS name for the
|
|
|
|
* constant and to access its value. Must be defined.
|
|
|
|
*
|
|
|
|
* Produces a |ConstantSpec|.
|
|
|
|
*/
|
|
|
|
#define INT_CONSTANT(name) \
|
2015-07-01 07:10:04 +03:00
|
|
|
{ #name, JS::Int32Value(name) }
|
2012-05-09 14:00:48 +04:00
|
|
|
|
2014-04-08 05:40:00 +04:00
|
|
|
/**
|
|
|
|
* Define a simple read-only property holding an unsigned integer.
|
|
|
|
*
|
|
|
|
* @param name The name of the constant. Used both as the JS name for the
|
|
|
|
* constant and to access its value. Must be defined.
|
|
|
|
*
|
|
|
|
* Produces a |ConstantSpec|.
|
|
|
|
*/
|
|
|
|
#define UINT_CONSTANT(name) \
|
2015-07-17 12:51:54 +03:00
|
|
|
{ #name, JS::NumberValue(name) }
|
2014-04-08 05:40:00 +04:00
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
/**
|
|
|
|
* End marker for ConstantSpec
|
|
|
|
*/
|
2013-10-28 18:04:47 +04:00
|
|
|
#define PROP_END { nullptr, JS::UndefinedValue() }
|
2012-05-09 14:00:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Define missing constants for Android
|
|
|
|
#if !defined(S_IRGRP)
|
|
|
|
#define S_IXOTH 0001
|
|
|
|
#define S_IWOTH 0002
|
|
|
|
#define S_IROTH 0004
|
|
|
|
#define S_IRWXO 0007
|
|
|
|
#define S_IXGRP 0010
|
|
|
|
#define S_IWGRP 0020
|
|
|
|
#define S_IRGRP 0040
|
|
|
|
#define S_IRWXG 0070
|
|
|
|
#define S_IXUSR 0100
|
|
|
|
#define S_IWUSR 0200
|
|
|
|
#define S_IRUSR 0400
|
|
|
|
#define S_IRWXU 0700
|
|
|
|
#endif // !defined(S_IRGRP)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The properties defined in libc.
|
|
|
|
*
|
|
|
|
* If you extend this list of properties, please
|
|
|
|
* separate categories ("errors", "open", etc.),
|
|
|
|
* keep properties organized by alphabetical order
|
|
|
|
* and #ifdef-away properties that are not portable.
|
|
|
|
*/
|
2013-08-09 17:46:07 +04:00
|
|
|
static const dom::ConstantSpec gLibcProperties[] =
|
2012-05-09 14:00:48 +04:00
|
|
|
{
|
|
|
|
// Arguments for open
|
|
|
|
INT_CONSTANT(O_APPEND),
|
2016-05-09 06:34:48 +03:00
|
|
|
#if defined(O_CLOEXEC)
|
|
|
|
INT_CONSTANT(O_CLOEXEC),
|
|
|
|
#endif // defined(O_CLOEXEC)
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(O_CREAT),
|
|
|
|
#if defined(O_DIRECTORY)
|
|
|
|
INT_CONSTANT(O_DIRECTORY),
|
|
|
|
#endif // defined(O_DIRECTORY)
|
|
|
|
#if defined(O_EVTONLY)
|
|
|
|
INT_CONSTANT(O_EVTONLY),
|
|
|
|
#endif // defined(O_EVTONLY)
|
|
|
|
INT_CONSTANT(O_EXCL),
|
|
|
|
#if defined(O_EXLOCK)
|
|
|
|
INT_CONSTANT(O_EXLOCK),
|
|
|
|
#endif // defined(O_EXLOCK)
|
|
|
|
#if defined(O_LARGEFILE)
|
|
|
|
INT_CONSTANT(O_LARGEFILE),
|
|
|
|
#endif // defined(O_LARGEFILE)
|
|
|
|
#if defined(O_NOFOLLOW)
|
|
|
|
INT_CONSTANT(O_NOFOLLOW),
|
|
|
|
#endif // defined(O_NOFOLLOW)
|
|
|
|
#if defined(O_NONBLOCK)
|
|
|
|
INT_CONSTANT(O_NONBLOCK),
|
|
|
|
#endif // defined(O_NONBLOCK)
|
|
|
|
INT_CONSTANT(O_RDONLY),
|
|
|
|
INT_CONSTANT(O_RDWR),
|
|
|
|
#if defined(O_RSYNC)
|
|
|
|
INT_CONSTANT(O_RSYNC),
|
|
|
|
#endif // defined(O_RSYNC)
|
|
|
|
#if defined(O_SHLOCK)
|
|
|
|
INT_CONSTANT(O_SHLOCK),
|
|
|
|
#endif // defined(O_SHLOCK)
|
|
|
|
#if defined(O_SYMLINK)
|
|
|
|
INT_CONSTANT(O_SYMLINK),
|
|
|
|
#endif // defined(O_SYMLINK)
|
|
|
|
#if defined(O_SYNC)
|
|
|
|
INT_CONSTANT(O_SYNC),
|
|
|
|
#endif // defined(O_SYNC)
|
|
|
|
INT_CONSTANT(O_TRUNC),
|
|
|
|
INT_CONSTANT(O_WRONLY),
|
|
|
|
|
2016-05-09 06:34:48 +03:00
|
|
|
#if defined(FD_CLOEXEC)
|
|
|
|
INT_CONSTANT(FD_CLOEXEC),
|
|
|
|
#endif // defined(FD_CLOEXEC)
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
#if defined(AT_EACCESS)
|
|
|
|
INT_CONSTANT(AT_EACCESS),
|
|
|
|
#endif //defined(AT_EACCESS)
|
|
|
|
#if defined(AT_FDCWD)
|
|
|
|
INT_CONSTANT(AT_FDCWD),
|
|
|
|
#endif //defined(AT_FDCWD)
|
|
|
|
#if defined(AT_SYMLINK_NOFOLLOW)
|
|
|
|
INT_CONSTANT(AT_SYMLINK_NOFOLLOW),
|
|
|
|
#endif //defined(AT_SYMLINK_NOFOLLOW)
|
|
|
|
|
2013-10-11 21:43:48 +04:00
|
|
|
#if defined(POSIX_FADV_SEQUENTIAL)
|
|
|
|
INT_CONSTANT(POSIX_FADV_SEQUENTIAL),
|
|
|
|
#endif //defined(POSIX_FADV_SEQUENTIAL)
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
// access
|
|
|
|
#if defined(F_OK)
|
|
|
|
INT_CONSTANT(F_OK),
|
|
|
|
INT_CONSTANT(R_OK),
|
|
|
|
INT_CONSTANT(W_OK),
|
|
|
|
INT_CONSTANT(X_OK),
|
|
|
|
#endif // defined(F_OK)
|
|
|
|
|
|
|
|
// modes
|
|
|
|
INT_CONSTANT(S_IRGRP),
|
|
|
|
INT_CONSTANT(S_IROTH),
|
|
|
|
INT_CONSTANT(S_IRUSR),
|
|
|
|
INT_CONSTANT(S_IRWXG),
|
|
|
|
INT_CONSTANT(S_IRWXO),
|
|
|
|
INT_CONSTANT(S_IRWXU),
|
|
|
|
INT_CONSTANT(S_IWGRP),
|
|
|
|
INT_CONSTANT(S_IWOTH),
|
|
|
|
INT_CONSTANT(S_IWUSR),
|
|
|
|
INT_CONSTANT(S_IXOTH),
|
|
|
|
INT_CONSTANT(S_IXGRP),
|
|
|
|
INT_CONSTANT(S_IXUSR),
|
|
|
|
|
|
|
|
// seek
|
|
|
|
INT_CONSTANT(SEEK_CUR),
|
|
|
|
INT_CONSTANT(SEEK_END),
|
|
|
|
INT_CONSTANT(SEEK_SET),
|
|
|
|
|
2014-11-21 05:20:41 +03:00
|
|
|
#if defined(XP_UNIX)
|
2016-05-09 06:34:48 +03:00
|
|
|
// poll
|
|
|
|
INT_CONSTANT(POLLERR),
|
|
|
|
INT_CONSTANT(POLLHUP),
|
|
|
|
INT_CONSTANT(POLLIN),
|
|
|
|
INT_CONSTANT(POLLNVAL),
|
|
|
|
INT_CONSTANT(POLLOUT),
|
|
|
|
|
|
|
|
// wait
|
2016-05-30 03:15:47 +03:00
|
|
|
#if defined(WNOHANG)
|
2016-05-09 06:34:48 +03:00
|
|
|
INT_CONSTANT(WNOHANG),
|
2016-05-30 03:15:47 +03:00
|
|
|
#endif // defined(WNOHANG)
|
2016-05-09 06:34:48 +03:00
|
|
|
|
|
|
|
// fcntl command values
|
2014-11-21 05:20:41 +03:00
|
|
|
INT_CONSTANT(F_GETLK),
|
2016-05-09 06:34:48 +03:00
|
|
|
INT_CONSTANT(F_SETFD),
|
|
|
|
INT_CONSTANT(F_SETFL),
|
2014-11-21 05:20:41 +03:00
|
|
|
INT_CONSTANT(F_SETLK),
|
|
|
|
INT_CONSTANT(F_SETLKW),
|
|
|
|
|
2016-05-09 06:34:48 +03:00
|
|
|
// flock type values
|
2014-11-21 05:20:41 +03:00
|
|
|
INT_CONSTANT(F_RDLCK),
|
|
|
|
INT_CONSTANT(F_WRLCK),
|
|
|
|
INT_CONSTANT(F_UNLCK),
|
2016-06-02 18:28:36 +03:00
|
|
|
|
|
|
|
// splice
|
|
|
|
#if defined(SPLICE_F_MOVE)
|
|
|
|
INT_CONSTANT(SPLICE_F_MOVE),
|
|
|
|
#endif // defined(SPLICE_F_MOVE)
|
|
|
|
#if defined(SPLICE_F_NONBLOCK)
|
|
|
|
INT_CONSTANT(SPLICE_F_NONBLOCK),
|
|
|
|
#endif // defined(SPLICE_F_NONBLOCK)
|
|
|
|
#if defined(SPLICE_F_MORE)
|
|
|
|
INT_CONSTANT(SPLICE_F_MORE),
|
|
|
|
#endif // defined(SPLICE_F_MORE)
|
|
|
|
#if defined(SPLICE_F_GIFT)
|
|
|
|
INT_CONSTANT(SPLICE_F_GIFT),
|
|
|
|
#endif // defined(SPLICE_F_GIFT)
|
2014-11-21 05:20:41 +03:00
|
|
|
#endif // defined(XP_UNIX)
|
2012-06-15 19:22:31 +04:00
|
|
|
// copyfile
|
|
|
|
#if defined(COPYFILE_DATA)
|
|
|
|
INT_CONSTANT(COPYFILE_DATA),
|
|
|
|
INT_CONSTANT(COPYFILE_EXCL),
|
|
|
|
INT_CONSTANT(COPYFILE_XATTR),
|
|
|
|
INT_CONSTANT(COPYFILE_STAT),
|
|
|
|
INT_CONSTANT(COPYFILE_ACL),
|
2012-08-06 04:12:58 +04:00
|
|
|
INT_CONSTANT(COPYFILE_MOVE),
|
2012-06-15 19:22:31 +04:00
|
|
|
#endif // defined(COPYFILE_DATA)
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
// error values
|
|
|
|
INT_CONSTANT(EACCES),
|
|
|
|
INT_CONSTANT(EAGAIN),
|
|
|
|
INT_CONSTANT(EBADF),
|
|
|
|
INT_CONSTANT(EEXIST),
|
|
|
|
INT_CONSTANT(EFAULT),
|
|
|
|
INT_CONSTANT(EFBIG),
|
|
|
|
INT_CONSTANT(EINVAL),
|
2017-06-07 02:00:53 +03:00
|
|
|
INT_CONSTANT(EINTR),
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EIO),
|
|
|
|
INT_CONSTANT(EISDIR),
|
2012-05-11 14:05:36 +04:00
|
|
|
#if defined(ELOOP) // not defined with VC9
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(ELOOP),
|
2012-05-11 14:05:36 +04:00
|
|
|
#endif // defined(ELOOP)
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EMFILE),
|
|
|
|
INT_CONSTANT(ENAMETOOLONG),
|
|
|
|
INT_CONSTANT(ENFILE),
|
|
|
|
INT_CONSTANT(ENOENT),
|
|
|
|
INT_CONSTANT(ENOMEM),
|
|
|
|
INT_CONSTANT(ENOSPC),
|
|
|
|
INT_CONSTANT(ENOTDIR),
|
|
|
|
INT_CONSTANT(ENXIO),
|
2012-05-11 14:05:36 +04:00
|
|
|
#if defined(EOPNOTSUPP) // not defined with VC 9
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EOPNOTSUPP),
|
2012-05-11 14:05:36 +04:00
|
|
|
#endif // defined(EOPNOTSUPP)
|
|
|
|
#if defined(EOVERFLOW) // not defined with VC 9
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EOVERFLOW),
|
2012-05-11 14:05:36 +04:00
|
|
|
#endif // defined(EOVERFLOW)
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EPERM),
|
|
|
|
INT_CONSTANT(ERANGE),
|
2012-05-11 14:05:36 +04:00
|
|
|
#if defined(ETIMEDOUT) // not defined with VC 9
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(ETIMEDOUT),
|
2012-05-11 14:05:36 +04:00
|
|
|
#endif // defined(ETIMEDOUT)
|
|
|
|
#if defined(EWOULDBLOCK) // not defined with VC 9
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EWOULDBLOCK),
|
2012-05-11 14:05:36 +04:00
|
|
|
#endif // defined(EWOULDBLOCK)
|
2012-05-09 14:00:48 +04:00
|
|
|
INT_CONSTANT(EXDEV),
|
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
#if defined(DT_UNKNOWN)
|
|
|
|
// Constants for |readdir|
|
|
|
|
INT_CONSTANT(DT_UNKNOWN),
|
|
|
|
INT_CONSTANT(DT_FIFO),
|
|
|
|
INT_CONSTANT(DT_CHR),
|
|
|
|
INT_CONSTANT(DT_DIR),
|
|
|
|
INT_CONSTANT(DT_BLK),
|
|
|
|
INT_CONSTANT(DT_REG),
|
|
|
|
INT_CONSTANT(DT_LNK),
|
|
|
|
INT_CONSTANT(DT_SOCK),
|
|
|
|
#endif // defined(DT_UNKNOWN)
|
|
|
|
|
2012-07-21 21:46:03 +04:00
|
|
|
#if defined(S_IFIFO)
|
|
|
|
// Constants for |stat|
|
|
|
|
INT_CONSTANT(S_IFMT),
|
|
|
|
INT_CONSTANT(S_IFIFO),
|
|
|
|
INT_CONSTANT(S_IFCHR),
|
|
|
|
INT_CONSTANT(S_IFDIR),
|
|
|
|
INT_CONSTANT(S_IFBLK),
|
|
|
|
INT_CONSTANT(S_IFREG),
|
|
|
|
INT_CONSTANT(S_IFLNK),
|
|
|
|
INT_CONSTANT(S_IFSOCK),
|
|
|
|
#endif // defined(S_IFIFO)
|
|
|
|
|
2014-05-05 14:53:00 +04:00
|
|
|
INT_CONSTANT(PATH_MAX),
|
|
|
|
|
2012-06-28 04:15:33 +04:00
|
|
|
// Constants used to define data structures
|
|
|
|
//
|
|
|
|
// Many data structures have different fields/sizes/etc. on
|
|
|
|
// various OSes / versions of the same OS / platforms. For these
|
|
|
|
// data structures, we need to compute and export from C the size
|
|
|
|
// and, if necessary, the offset of fields, so as to be able to
|
|
|
|
// define the structure in JS.
|
|
|
|
|
|
|
|
#if defined(XP_UNIX)
|
|
|
|
// The size of |mode_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_MODE_T", JS::Int32Value(sizeof (mode_t)) },
|
2012-07-05 12:20:38 +04:00
|
|
|
|
2012-07-21 21:46:03 +04:00
|
|
|
// The size of |gid_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_GID_T", JS::Int32Value(sizeof (gid_t)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
|
|
|
|
// The size of |uid_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_UID_T", JS::Int32Value(sizeof (uid_t)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
|
|
|
|
// The size of |time_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_TIME_T", JS::Int32Value(sizeof (time_t)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
|
2014-01-15 11:04:00 +04:00
|
|
|
// The size of |fsblkcnt_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_FSBLKCNT_T", JS::Int32Value(sizeof (fsblkcnt_t)) },
|
2014-01-15 11:04:00 +04:00
|
|
|
|
2013-11-18 22:04:33 +04:00
|
|
|
#if !defined(ANDROID)
|
|
|
|
// The size of |posix_spawn_file_actions_t|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_POSIX_SPAWN_FILE_ACTIONS_T", JS::Int32Value(sizeof (posix_spawn_file_actions_t)) },
|
2013-11-18 22:04:33 +04:00
|
|
|
#endif // !defined(ANDROID)
|
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
// Defining |dirent|.
|
|
|
|
// Size
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_DIRENT", JS::Int32Value(sizeof (dirent)) },
|
2012-07-05 12:20:38 +04:00
|
|
|
|
2014-11-21 05:20:41 +03:00
|
|
|
// Defining |flock|.
|
|
|
|
#if defined(XP_UNIX)
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_FLOCK", JS::Int32Value(sizeof (struct flock)) },
|
|
|
|
{ "OSFILE_OFFSETOF_FLOCK_L_START", JS::Int32Value(offsetof (struct flock, l_start)) },
|
|
|
|
{ "OSFILE_OFFSETOF_FLOCK_L_LEN", JS::Int32Value(offsetof (struct flock, l_len)) },
|
|
|
|
{ "OSFILE_OFFSETOF_FLOCK_L_PID", JS::Int32Value(offsetof (struct flock, l_pid)) },
|
|
|
|
{ "OSFILE_OFFSETOF_FLOCK_L_TYPE", JS::Int32Value(offsetof (struct flock, l_type)) },
|
|
|
|
{ "OSFILE_OFFSETOF_FLOCK_L_WHENCE", JS::Int32Value(offsetof (struct flock, l_whence)) },
|
2014-11-21 05:20:41 +03:00
|
|
|
#endif // defined(XP_UNIX)
|
2012-07-05 12:20:38 +04:00
|
|
|
// Offset of field |d_name|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_DIRENT_D_NAME", JS::Int32Value(offsetof (struct dirent, d_name)) },
|
2012-07-05 12:20:38 +04:00
|
|
|
// An upper bound to the length of field |d_name| of struct |dirent|.
|
|
|
|
// (may not be exact, depending on padding).
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_DIRENT_D_NAME", JS::Int32Value(sizeof (struct dirent) - offsetof (struct dirent, d_name)) },
|
2012-07-05 12:20:38 +04:00
|
|
|
|
2013-10-28 09:40:00 +04:00
|
|
|
// Defining |timeval|.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_TIMEVAL", JS::Int32Value(sizeof (struct timeval)) },
|
|
|
|
{ "OSFILE_OFFSETOF_TIMEVAL_TV_SEC", JS::Int32Value(offsetof (struct timeval, tv_sec)) },
|
|
|
|
{ "OSFILE_OFFSETOF_TIMEVAL_TV_USEC", JS::Int32Value(offsetof (struct timeval, tv_usec)) },
|
2013-10-28 09:40:00 +04:00
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
#if defined(DT_UNKNOWN)
|
|
|
|
// Position of field |d_type| in |dirent|
|
|
|
|
// Not strictly posix, but seems defined on all platforms
|
|
|
|
// except mingw32.
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_DIRENT_D_TYPE", JS::Int32Value(offsetof (struct dirent, d_type)) },
|
2012-07-05 12:20:38 +04:00
|
|
|
#endif // defined(DT_UNKNOWN)
|
|
|
|
|
2012-12-02 06:25:24 +04:00
|
|
|
// Under MacOS X and BSDs, |dirfd| is a macro rather than a
|
|
|
|
// function, so we need a little help to get it to work
|
2012-10-30 19:34:49 +04:00
|
|
|
#if defined(dirfd)
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_DIR", JS::Int32Value(sizeof (DIR)) },
|
2012-10-30 19:34:49 +04:00
|
|
|
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_DIR_DD_FD", JS::Int32Value(offsetof (DIR, __dd_fd)) },
|
2012-10-30 19:34:49 +04:00
|
|
|
#endif
|
2012-07-21 21:46:03 +04:00
|
|
|
|
|
|
|
// Defining |stat|
|
|
|
|
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_STAT", JS::Int32Value(sizeof (struct stat)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_MODE", JS::Int32Value(offsetof (struct stat, st_mode)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_UID", JS::Int32Value(offsetof (struct stat, st_uid)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_GID", JS::Int32Value(offsetof (struct stat, st_gid)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_SIZE", JS::Int32Value(offsetof (struct stat, st_size)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
|
|
|
|
#if defined(HAVE_ST_ATIMESPEC)
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", JS::Int32Value(offsetof (struct stat, st_atimespec)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", JS::Int32Value(offsetof (struct stat, st_mtimespec)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", JS::Int32Value(offsetof (struct stat, st_ctimespec)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
#else
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_ATIME", JS::Int32Value(offsetof (struct stat, st_atime)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_MTIME", JS::Int32Value(offsetof (struct stat, st_mtime)) },
|
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_CTIME", JS::Int32Value(offsetof (struct stat, st_ctime)) },
|
2012-07-21 21:46:03 +04:00
|
|
|
#endif // defined(HAVE_ST_ATIME)
|
|
|
|
|
2012-11-15 23:22:27 +04:00
|
|
|
// Several OSes have a birthtime field. For the moment, supporting only Darwin.
|
|
|
|
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_STAT_ST_BIRTHTIME", JS::Int32Value(offsetof (struct stat, st_birthtime)) },
|
2012-11-15 23:22:27 +04:00
|
|
|
#endif // defined(_DARWIN_FEATURE_64_BIT_INODE)
|
|
|
|
|
2014-01-15 11:04:00 +04:00
|
|
|
// Defining |statvfs|
|
|
|
|
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_SIZEOF_STATVFS", JS::Int32Value(sizeof (struct statvfs)) },
|
2014-01-15 11:04:00 +04:00
|
|
|
|
2014-03-09 07:30:00 +04:00
|
|
|
{ "OSFILE_OFFSETOF_STATVFS_F_FRSIZE", JS::Int32Value(offsetof (struct statvfs, f_frsize)) },
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "OSFILE_OFFSETOF_STATVFS_F_BAVAIL", JS::Int32Value(offsetof (struct statvfs, f_bavail)) },
|
2014-01-15 11:04:00 +04:00
|
|
|
|
2012-06-28 04:15:33 +04:00
|
|
|
#endif // defined(XP_UNIX)
|
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
|
2012-07-21 21:46:03 +04:00
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
// System configuration
|
|
|
|
|
|
|
|
// Under MacOSX, to avoid using deprecated functions that do not
|
|
|
|
// match the constants we define in this object (including
|
|
|
|
// |sizeof|/|offsetof| stuff, but not only), for a number of
|
|
|
|
// functions, we need to adapt the name of the symbols we are using,
|
|
|
|
// whenever macro _DARWIN_FEATURE_64_BIT_INODE is set. We export
|
|
|
|
// this value to be able to do so from JavaScript.
|
|
|
|
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "_DARWIN_FEATURE_64_BIT_INODE", JS::Int32Value(1) },
|
2012-07-21 21:46:03 +04:00
|
|
|
#endif // defined(_DARWIN_FEATURE_64_BIT_INODE)
|
|
|
|
|
|
|
|
// Similar feature for Linux
|
|
|
|
#if defined(_STAT_VER)
|
|
|
|
INT_CONSTANT(_STAT_VER),
|
|
|
|
#endif // defined(_STAT_VER)
|
2012-07-05 12:20:38 +04:00
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
PROP_END
|
|
|
|
};
|
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
/**
|
|
|
|
* The properties defined in windows.h.
|
|
|
|
*
|
|
|
|
* If you extend this list of properties, please
|
|
|
|
* separate categories ("errors", "open", etc.),
|
|
|
|
* keep properties organized by alphabetical order
|
|
|
|
* and #ifdef-away properties that are not portable.
|
|
|
|
*/
|
2013-08-09 17:46:07 +04:00
|
|
|
static const dom::ConstantSpec gWinProperties[] =
|
2012-05-09 14:05:22 +04:00
|
|
|
{
|
|
|
|
// FormatMessage flags
|
|
|
|
INT_CONSTANT(FORMAT_MESSAGE_FROM_SYSTEM),
|
|
|
|
INT_CONSTANT(FORMAT_MESSAGE_IGNORE_INSERTS),
|
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
// The max length of paths
|
|
|
|
INT_CONSTANT(MAX_PATH),
|
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
// CreateFile desired access
|
|
|
|
INT_CONSTANT(GENERIC_ALL),
|
|
|
|
INT_CONSTANT(GENERIC_EXECUTE),
|
|
|
|
INT_CONSTANT(GENERIC_READ),
|
|
|
|
INT_CONSTANT(GENERIC_WRITE),
|
|
|
|
|
|
|
|
// CreateFile share mode
|
|
|
|
INT_CONSTANT(FILE_SHARE_DELETE),
|
|
|
|
INT_CONSTANT(FILE_SHARE_READ),
|
|
|
|
INT_CONSTANT(FILE_SHARE_WRITE),
|
|
|
|
|
|
|
|
// CreateFile creation disposition
|
|
|
|
INT_CONSTANT(CREATE_ALWAYS),
|
|
|
|
INT_CONSTANT(CREATE_NEW),
|
|
|
|
INT_CONSTANT(OPEN_ALWAYS),
|
|
|
|
INT_CONSTANT(OPEN_EXISTING),
|
|
|
|
INT_CONSTANT(TRUNCATE_EXISTING),
|
|
|
|
|
|
|
|
// CreateFile attributes
|
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_ARCHIVE),
|
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY),
|
2015-03-13 18:51:53 +03:00
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_HIDDEN),
|
2012-05-09 14:05:22 +04:00
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_NORMAL),
|
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_READONLY),
|
2012-07-05 12:20:38 +04:00
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_REPARSE_POINT),
|
2015-03-13 18:51:53 +03:00
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_SYSTEM),
|
2012-05-09 14:05:22 +04:00
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_TEMPORARY),
|
2012-07-21 21:47:59 +04:00
|
|
|
INT_CONSTANT(FILE_FLAG_BACKUP_SEMANTICS),
|
2012-05-09 14:05:22 +04:00
|
|
|
|
2012-06-15 19:22:21 +04:00
|
|
|
// CreateFile error constant
|
2015-07-01 07:10:04 +03:00
|
|
|
{ "INVALID_HANDLE_VALUE", JS::Int32Value(INT_PTR(INVALID_HANDLE_VALUE)) },
|
2012-05-09 14:05:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
// CreateFile flags
|
|
|
|
INT_CONSTANT(FILE_FLAG_DELETE_ON_CLOSE),
|
|
|
|
|
|
|
|
// SetFilePointer methods
|
|
|
|
INT_CONSTANT(FILE_BEGIN),
|
|
|
|
INT_CONSTANT(FILE_CURRENT),
|
|
|
|
INT_CONSTANT(FILE_END),
|
|
|
|
|
|
|
|
// SetFilePointer error constant
|
2014-04-08 05:40:00 +04:00
|
|
|
UINT_CONSTANT(INVALID_SET_FILE_POINTER),
|
2012-05-09 14:05:22 +04:00
|
|
|
|
2012-07-05 12:20:38 +04:00
|
|
|
// File attributes
|
|
|
|
INT_CONSTANT(FILE_ATTRIBUTE_DIRECTORY),
|
|
|
|
|
|
|
|
|
2012-06-23 04:24:27 +04:00
|
|
|
// MoveFile flags
|
|
|
|
INT_CONSTANT(MOVEFILE_COPY_ALLOWED),
|
|
|
|
INT_CONSTANT(MOVEFILE_REPLACE_EXISTING),
|
|
|
|
|
2013-10-29 12:27:01 +04:00
|
|
|
// GetFileAttributes error constant
|
|
|
|
INT_CONSTANT(INVALID_FILE_ATTRIBUTES),
|
|
|
|
|
2014-01-22 21:33:48 +04:00
|
|
|
// GetNamedSecurityInfo and SetNamedSecurityInfo constants
|
|
|
|
INT_CONSTANT(UNPROTECTED_DACL_SECURITY_INFORMATION),
|
|
|
|
INT_CONSTANT(SE_FILE_OBJECT),
|
|
|
|
INT_CONSTANT(DACL_SECURITY_INFORMATION),
|
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
// Errors
|
2014-02-24 19:16:01 +04:00
|
|
|
INT_CONSTANT(ERROR_INVALID_HANDLE),
|
2012-07-05 12:20:38 +04:00
|
|
|
INT_CONSTANT(ERROR_ACCESS_DENIED),
|
2012-08-25 00:18:15 +04:00
|
|
|
INT_CONSTANT(ERROR_DIR_NOT_EMPTY),
|
2012-06-15 19:22:21 +04:00
|
|
|
INT_CONSTANT(ERROR_FILE_EXISTS),
|
2012-08-25 00:18:15 +04:00
|
|
|
INT_CONSTANT(ERROR_ALREADY_EXISTS),
|
2012-05-09 14:05:22 +04:00
|
|
|
INT_CONSTANT(ERROR_FILE_NOT_FOUND),
|
2012-07-05 12:20:38 +04:00
|
|
|
INT_CONSTANT(ERROR_NO_MORE_FILES),
|
2013-02-26 21:06:53 +04:00
|
|
|
INT_CONSTANT(ERROR_PATH_NOT_FOUND),
|
2014-03-14 18:13:26 +04:00
|
|
|
INT_CONSTANT(ERROR_BAD_ARGUMENTS),
|
2014-05-08 22:06:26 +04:00
|
|
|
INT_CONSTANT(ERROR_SHARING_VIOLATION),
|
2014-03-14 18:13:26 +04:00
|
|
|
INT_CONSTANT(ERROR_NOT_SUPPORTED),
|
2012-05-09 14:05:22 +04:00
|
|
|
|
|
|
|
PROP_END
|
|
|
|
};
|
|
|
|
#endif // defined(XP_WIN)
|
|
|
|
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
/**
|
|
|
|
* Get a field of an object as an object.
|
|
|
|
*
|
|
|
|
* If the field does not exist, create it. If it exists but is not an
|
|
|
|
* object, throw a JS error.
|
|
|
|
*/
|
2013-05-11 06:39:45 +04:00
|
|
|
JSObject *GetOrCreateObjectProperty(JSContext *cx, JS::Handle<JSObject*> aObject,
|
2012-05-09 14:00:48 +04:00
|
|
|
const char *aProperty)
|
|
|
|
{
|
2013-05-04 11:52:57 +04:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
2013-07-26 13:00:38 +04:00
|
|
|
if (!JS_GetProperty(cx, aObject, aProperty, &val)) {
|
2013-10-28 18:04:47 +04:00
|
|
|
return nullptr;
|
2012-06-02 22:15:38 +04:00
|
|
|
}
|
|
|
|
if (!val.isUndefined()) {
|
|
|
|
if (val.isObject()) {
|
|
|
|
return &val.toObject();
|
2012-05-09 14:00:48 +04:00
|
|
|
}
|
2012-06-02 22:15:38 +04:00
|
|
|
|
2016-08-15 17:05:04 +03:00
|
|
|
JS_ReportErrorNumberASCII(cx, js::GetErrorMessage, nullptr,
|
|
|
|
JSMSG_UNEXPECTED_TYPE,
|
|
|
|
aProperty, "not an object");
|
2013-10-28 18:04:47 +04:00
|
|
|
return nullptr;
|
2012-05-09 14:00:48 +04:00
|
|
|
}
|
2015-02-05 00:50:17 +03:00
|
|
|
return JS_DefineObject(cx, aObject, aProperty, nullptr, JSPROP_ENUMERATE);
|
2012-05-09 14:00:48 +04:00
|
|
|
}
|
|
|
|
|
2012-08-23 00:58:08 +04:00
|
|
|
/**
|
|
|
|
* Set a property of an object from a nsString.
|
2012-08-23 00:58:09 +04:00
|
|
|
*
|
|
|
|
* If the nsString is void (i.e. IsVoid is true), do nothing.
|
2012-08-23 00:58:08 +04:00
|
|
|
*/
|
2013-05-11 06:39:45 +04:00
|
|
|
bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char *aProperty,
|
2012-08-23 00:58:08 +04:00
|
|
|
const nsString aValue)
|
|
|
|
{
|
2012-08-23 00:58:09 +04:00
|
|
|
if (aValue.IsVoid()) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-23 00:58:08 +04:00
|
|
|
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
|
2012-12-23 03:35:07 +04:00
|
|
|
NS_ENSURE_TRUE(strValue, false);
|
2015-06-30 21:20:56 +03:00
|
|
|
JS::Rooted<JS::Value> valValue(cx, JS::StringValue(strValue));
|
2013-07-26 13:00:38 +04:00
|
|
|
return JS_SetProperty(cx, aObject, aProperty, valValue);
|
2012-08-23 00:58:08 +04:00
|
|
|
}
|
|
|
|
|
2012-05-09 14:00:48 +04:00
|
|
|
/**
|
|
|
|
* Define OS-specific constants.
|
|
|
|
*
|
|
|
|
* This function creates or uses JS object |OS.Constants| to store
|
|
|
|
* all its constants.
|
|
|
|
*/
|
2017-11-10 21:27:03 +03:00
|
|
|
bool
|
|
|
|
OSFileConstantsService::DefineOSFileConstants(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGlobal)
|
2012-05-09 14:00:48 +04:00
|
|
|
{
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!mInitialized) {
|
2017-11-10 21:27:03 +03:00
|
|
|
JS_ReportErrorNumberASCII(aCx, js::GetErrorMessage, nullptr,
|
2016-08-15 13:21:05 +03:00
|
|
|
JSMSG_CANT_OPEN,
|
|
|
|
"OSFileConstants", "initialization has failed");
|
2012-08-23 00:58:08 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objOS(aCx);
|
|
|
|
if (!(objOS = GetOrCreateObjectProperty(aCx, aGlobal, "OS"))) {
|
2012-05-09 14:00:48 +04:00
|
|
|
return false;
|
|
|
|
}
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objConstants(aCx);
|
|
|
|
if (!(objConstants = GetOrCreateObjectProperty(aCx, objOS, "Constants"))) {
|
2012-05-09 14:00:48 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-06-29 05:56:30 +04:00
|
|
|
|
|
|
|
// Build OS.Constants.libc
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objLibc(aCx);
|
|
|
|
if (!(objLibc = GetOrCreateObjectProperty(aCx, objConstants, "libc"))) {
|
2012-05-09 14:00:48 +04:00
|
|
|
return false;
|
|
|
|
}
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!dom::DefineConstants(aCx, objLibc, gLibcProperties)) {
|
2012-05-09 14:05:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
2012-06-29 05:56:30 +04:00
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
#if defined(XP_WIN)
|
2012-06-29 05:56:30 +04:00
|
|
|
// Build OS.Constants.Win
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objWin(aCx);
|
|
|
|
if (!(objWin = GetOrCreateObjectProperty(aCx, objConstants, "Win"))) {
|
2012-05-09 14:05:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!dom::DefineConstants(aCx, objWin, gWinProperties)) {
|
2012-05-09 14:05:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // defined(XP_WIN)
|
2012-06-29 05:56:30 +04:00
|
|
|
|
|
|
|
// Build OS.Constants.Sys
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objSys(aCx);
|
|
|
|
if (!(objSys = GetOrCreateObjectProperty(aCx, objConstants, "Sys"))) {
|
2012-06-21 23:58:25 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULRuntime> runtime = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
|
|
|
|
if (runtime) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString os;
|
2012-06-29 05:56:30 +04:00
|
|
|
DebugOnly<nsresult> rv = runtime->GetOS(os);
|
2012-06-21 23:58:25 +04:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JSString* strVersion = JS_NewStringCopyZ(aCx, os.get());
|
2012-06-21 23:58:25 +04:00
|
|
|
if (!strVersion) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JS::Value> valVersion(aCx, JS::StringValue(strVersion));
|
|
|
|
if (!JS_SetProperty(aCx, objSys, "Name", valVersion)) {
|
2012-06-21 23:58:25 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-24 16:36:10 +04:00
|
|
|
#if defined(DEBUG)
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JS::Value> valDebug(aCx, JS::TrueValue());
|
|
|
|
if (!JS_SetProperty(aCx, objSys, "DEBUG", valDebug)) {
|
2013-04-24 16:36:10 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-26 16:53:20 +03:00
|
|
|
#if defined(HAVE_64BIT_BUILD)
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JS::Value> valBits(aCx, JS::Int32Value(64));
|
2015-02-26 16:53:20 +03:00
|
|
|
#else
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JS::Value> valBits(aCx, JS::Int32Value(32));
|
2015-02-26 16:53:20 +03:00
|
|
|
#endif //defined (HAVE_64BIT_BUILD)
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!JS_SetProperty(aCx, objSys, "bits", valBits)) {
|
2015-02-26 16:53:20 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!JS_DefineProperty(aCx, objSys, "umask", mUserUmask,
|
2016-03-11 02:07:28 +03:00
|
|
|
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)) {
|
2014-04-26 18:56:58 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-04 02:40:53 +04:00
|
|
|
// Build OS.Constants.Path
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
JS::Rooted<JSObject*> objPath(aCx);
|
|
|
|
if (!(objPath = GetOrCreateObjectProperty(aCx, objConstants, "Path"))) {
|
2012-07-04 02:40:53 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
// Locate libxul
|
2013-11-25 18:32:29 +04:00
|
|
|
// Note that we don't actually provide the full path, only the name of the
|
|
|
|
// library, which is sufficient to link to the library using js-ctypes.
|
2014-01-21 20:29:29 +04:00
|
|
|
|
2012-06-29 05:56:30 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2014-02-05 22:29:51 +04:00
|
|
|
// Under MacOS X, for some reason, libxul is called simply "XUL",
|
|
|
|
// and we need to provide the full path.
|
|
|
|
nsAutoString libxul;
|
2017-11-10 21:27:55 +03:00
|
|
|
libxul.Append(mPaths->libDir);
|
2014-05-22 07:48:50 +04:00
|
|
|
libxul.AppendLiteral("/XUL");
|
2012-06-29 05:56:30 +04:00
|
|
|
#else
|
2014-01-21 20:29:29 +04:00
|
|
|
// On other platforms, libxul is a library "xul" with regular
|
2014-02-05 22:29:51 +04:00
|
|
|
// library prefix/suffix.
|
2014-01-21 20:29:29 +04:00
|
|
|
nsAutoString libxul;
|
2014-05-22 07:48:50 +04:00
|
|
|
libxul.AppendLiteral(DLL_PREFIX);
|
|
|
|
libxul.AppendLiteral("xul");
|
|
|
|
libxul.AppendLiteral(DLL_SUFFIX);
|
2012-06-29 05:56:30 +04:00
|
|
|
#endif // defined(XP_MACOSX)
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "libxul", libxul)) {
|
2014-01-21 20:29:29 +04:00
|
|
|
return false;
|
2012-06-29 05:56:30 +04:00
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "libDir", mPaths->libDir)) {
|
2012-08-23 00:58:08 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "tmpDir", mPaths->tmpDir)) {
|
2012-08-23 00:58:08 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-12-12 03:12:59 +04:00
|
|
|
// Configure profileDir only if it is available at this stage
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!mPaths->profileDir.IsVoid()
|
|
|
|
&& !SetStringProperty(aCx, objPath, "profileDir", mPaths->profileDir)) {
|
2012-08-23 00:58:08 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-12-12 03:12:59 +04:00
|
|
|
// Configure localProfileDir only if it is available at this stage
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!mPaths->localProfileDir.IsVoid()
|
|
|
|
&& !SetStringProperty(aCx, objPath, "localProfileDir", mPaths->localProfileDir)) {
|
2012-12-02 06:20:44 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "homeDir", mPaths->homeDir)) {
|
2013-09-30 18:59:41 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "userApplicationDataDir", mPaths->userApplicationDataDir)) {
|
2014-01-13 17:45:20 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-30 18:59:41 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2017-11-10 21:27:55 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "macUserLibDir", mPaths->macUserLibDir)) {
|
2013-09-30 18:59:41 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // defined(XP_MACOSX)
|
|
|
|
|
2014-01-21 20:29:29 +04:00
|
|
|
// sqlite3 is linked from different places depending on the platform
|
|
|
|
nsAutoString libsqlite3;
|
|
|
|
#if defined(ANDROID)
|
|
|
|
// On Android, we use the system's libsqlite3
|
2014-05-22 07:48:50 +04:00
|
|
|
libsqlite3.AppendLiteral(DLL_PREFIX);
|
|
|
|
libsqlite3.AppendLiteral("sqlite3");
|
|
|
|
libsqlite3.AppendLiteral(DLL_SUFFIX);
|
2014-01-21 20:29:29 +04:00
|
|
|
#elif defined(XP_WIN)
|
|
|
|
// On Windows, for some reason, this is part of nss3.dll
|
2014-05-22 07:48:50 +04:00
|
|
|
libsqlite3.AppendLiteral(DLL_PREFIX);
|
|
|
|
libsqlite3.AppendLiteral("nss3");
|
|
|
|
libsqlite3.AppendLiteral(DLL_SUFFIX);
|
2014-01-21 20:29:29 +04:00
|
|
|
#else
|
|
|
|
// On other platforms, we link sqlite3 into libxul
|
|
|
|
libsqlite3 = libxul;
|
|
|
|
#endif // defined(ANDROID) || defined(XP_WIN)
|
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!SetStringProperty(aCx, objPath, "libsqlite3", libsqlite3)) {
|
2014-01-21 20:29:29 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-09 14:05:22 +04:00
|
|
|
return true;
|
2012-05-09 14:00:48 +04:00
|
|
|
}
|
|
|
|
|
2017-11-10 21:27:29 +03:00
|
|
|
NS_IMPL_ISUPPORTS(OSFileConstantsService, nsIOSFileConstantsService,
|
|
|
|
nsIObserver)
|
2012-07-04 16:30:58 +04:00
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
/* static */ already_AddRefed<OSFileConstantsService>
|
|
|
|
OSFileConstantsService::GetOrCreate()
|
|
|
|
{
|
|
|
|
if (!gInstance) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
RefPtr<OSFileConstantsService> service = new OSFileConstantsService();
|
|
|
|
nsresult rv = service->InitOSFileConstants();
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
gInstance = service.forget();
|
|
|
|
ClearOnShutdown(&gInstance);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<OSFileConstantsService> copy = gInstance;
|
|
|
|
return copy.forget();
|
|
|
|
}
|
|
|
|
|
2012-07-04 16:30:58 +04:00
|
|
|
OSFileConstantsService::OSFileConstantsService()
|
2017-11-10 21:27:03 +03:00
|
|
|
: mInitialized(false)
|
2017-11-10 21:27:55 +03:00
|
|
|
, mUserUmask(0)
|
2012-07-04 16:30:58 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
|
|
|
|
OSFileConstantsService::~OSFileConstantsService()
|
|
|
|
{
|
2017-11-10 21:27:03 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
2012-07-04 16:30:58 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
OSFileConstantsService::Init(JSContext *aCx)
|
|
|
|
{
|
2017-11-10 21:27:03 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsresult rv = InitOSFileConstants();
|
2012-07-04 16:30:58 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2012-05-09 14:00:48 +04:00
|
|
|
|
2012-11-26 20:55:12 +04:00
|
|
|
mozJSComponentLoader* loader = mozJSComponentLoader::Get();
|
2013-04-23 19:48:05 +04:00
|
|
|
JS::Rooted<JSObject*> targetObj(aCx);
|
2017-05-17 00:27:50 +03:00
|
|
|
loader->FindTargetObject(aCx, &targetObj);
|
2012-11-26 20:55:12 +04:00
|
|
|
|
2017-11-10 21:27:03 +03:00
|
|
|
if (!DefineOSFileConstants(aCx, targetObj)) {
|
2012-07-04 16:30:58 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|