JavaScript module OS.Constants
contains Operating System-specific constants. This module is largely a companion to js-ctypes.
To initialize OS.Constants
for use in the main thread, add the following snippet to your code:
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]. getService(Components.interfaces.nsIOSFileConstantsService). init();
No initialization is required. Module OS.Constants
is always available for chrome workers.
Constants related to system configuration.
Name |
The name of the operating system (e.g. "Darwin"). |
DEBUG | Set to true on debug build configurations, non-existent otherwise. |
Paths of well-known files and directories.
libxul |
The path to the file containing libxul. Useful, for instance, to access the platform code from JavaScript in conjunction with js-ctypes. |
profileDir |
The path to the current profile. |
homeDir |
The path to the user's home directory. |
winAppDataDir |
The path to the user's roaming application data directory. |
winLocalAppDataDir |
The path to the user's local application data directory. |
winStartMenuProgsDir |
The path to the programs subdirectory in the user's start menu. |
macUserLibDir |
The path to the user's Library directory. |
macLocalApplicationsDir |
The path to the local Applications directory. |
Constants for interacting with libc. Useful mostly for using js-ctypes to interact with the following platforms:
OS.Constants.libc
is available on all platforms, although some constants are not defined everywhere. Before using a constant, you should check that it is defined.
EACCES | Permission denied |
EAGAIN | Resource temporarily unavailable |
EBADF | Bad file descriptor |
EEXIST | File exists |
EFAULT | Bad address |
EFBIG | File too large |
EINVAL | Invalid argument |
EIO | Input/output error |
EISDIR | Is a directory |
ELOOP |
(Not always available under Windows) Too many levels of symbolic links. |
EMFILE | Too many open files in the process |
ENAMETOOLONG | Name too long |
ENFILE | Too many open files on the system |
ENOENT | No such file or directory |
ENOMEM | Cannot allocate memory |
ENOSPC | No space on device |
ENOTDIR | Is not a directory |
ENXIO | Device no configured or does not support operation |
EOPNOTSUPP | (Not always available under Windows) Operation not supported. |
EOVERFLOW | (Not always available under Windows) Value too large to be stored in datatype. |
EPERM | Operation not permitted |
ERANGE | Result too large |
ETIMEDOUT | (Not always available under Windows) Operation timed out. |
EWOULDBLOCK | (Not always available under Windows) Operation would block. |
EXDEV | Cross-device link |
Defined on all platforms but meaningful only on Unix.
Constants for interacting with the Windows API. OS.Constants.Win
is undefined
on non-Windows platforms. Useful mostly in conjunction with js-ctypes.
(tbd)