JavaScript OS.Constants

  • Revision slug: JavaScript_OS.Constants
  • Revision title: JavaScript OS.Constants
  • Revision id: 235377
  • Created:
  • Creator: Yoric
  • Is current revision? No
  • Comment 140 words added

Revision Content

JavaScript module OS.Constants contains Operating System-specific constants.

At the time of this writing, this module is available only to chrome workers.

OS.Constants.Sys

(tbd)

OS.Constants.libc

Constants for interacting with libc. Useful mostly for using js-ctypes to interact with the following platforms:

  • MacOS X;
  • Android;
  • Linux;
  • other variants of Unix.

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.

Error values

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

Too many levels of symbolic links.
May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.

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 Operation not supported.
May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.
EOVERFLOW Value too large to be stored in datatype.
May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.
EPERM Operation not permitted
ERANGE Result too large
ETIMEDOUT Operation timed out.
May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.
EWOULDBLOCK Operation would block.
May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.
EXDEV Cross-device link

Opening files

Unix access rights.

Defined on all platforms but meaningful only on Unix.

S_IRWXU Current User can Read, Write, eXecute the file. Equivalent to S_IRUSR | S_IWUSR | S_IXUSR.
S_IRUSR Current User can Read the file.
S_IWUSR Current User can Write (modify) the file.
S_IXUSR Current User can eXecute the file.
S_IRWXG Current GRouP of the current user can Read, Write, eXecute the file. Equivalent to S_IRGRP | S_IWGRP | S_IXGRP.
S_IRGRP Current GRouP of the current user can Read the file.
S_IWGRP Current GRouP of the current user can Write (modify) the file.
S_IXGRP Current GRouP of the current user can eXecute the file.
S_IRWXO All Other users can Read, Write, eXecute the file. Equivalent to S_IROTH | S_IWOTH | S_IXOTH.
S_IROTH All Other users can Read the file.
S_IWOTH All Other users can Write (modify) the file.
S_IXOTH All Other users can eXecute the file.

Unix opening mode

O_APPEND Open the file for appending.
O_CREAT Create the file if it does not exist yet.
O_DIRECTORY (Linux only) Succeed only of the file is a directory.
O_EVTONLY Descriptor requested for event notifications only.
O_EXCL Raise an error if O_CREAT is set and the file exists.
O_EXLOCK Atomically obtain an exclusive lock.
O_LARGEFILE  
O_NOFOLLOW Do not follow symbolic links.
O_NONBLOCK Do not block on open or for data to become available.
O_RDONLY Open the file for read only.
O_RDWR Open the file for read and write.
O_RSYNC  
O_SHLOCK Atomically obtain a shared lock.
O_SYMLINK Allow opening of symbolic links.
O_SYNC (Linux only) Open for purely synchronous access.
O_TRUNC Truncate the file.
O_WRONLY Open the file for write only.

OS.Constants.Win

Constants for interacting with the Windows API. OS.Constants.Win is undefined on non-Windows platforms. Useful mostly in conjunction with js-ctypes.

(tbd)

Revision Source

<p>JavaScript module <code>OS.Constants</code> contains Operating System-specific constants.</p>
<p>At the time of this writing, this module is available only to <a href="/en/DOM/ChromeWorker" rel="internal" title="ChromeWorker">chrome workers</a>.</p>
<h2>OS.Constants.Sys</h2>
<p>(tbd)</p><h2>OS.Constants.libc</h2>
<p>Constants for interacting with libc. Useful mostly for using <a href="/en/js-ctypes" title="en/js-ctypes">js-ctypes</a> to interact with the following platforms:</p>
<ul> <li>MacOS X;</li> <li>Android;</li> <li>Linux;</li> <li>other variants of Unix.</li>
</ul>
<p><code>OS.Constants.libc</code> is available on all platforms, although some constants are not defined everywhere. Before using a constant, you should check that it is defined.</p>
<h3>Error values</h3>
<table border="1" cellpadding="1" cellspacing="1" style="table-layout: fixed;"> <tbody> <tr> <td>EACCES</td> <td>Permission denied</td> </tr> <tr> <td>EAGAIN</td> <td>Resource temporarily unavailable</td> </tr> <tr> <td>EBADF</td> <td>Bad file descriptor</td> </tr> <tr> <td>EEXIST</td> <td>File exists</td> </tr> <tr> <td>EFAULT</td> <td>Bad address</td> </tr> <tr> <td>EFBIG</td> <td>File too large</td> </tr> <tr> <td>EINVAL</td> <td>Invalid argument</td> </tr> <tr> <td>EIO</td> <td>Input/output error</td> </tr> <tr> <td>EISDIR</td> <td>Is a directory</td> </tr> <tr> <td>ELOOP</td> <td> <p>Too many levels of symbolic links.<br> <span style="color:#a9a9a9;">May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.</span></p> </td> </tr> <tr> <td>EMFILE</td> <td>Too many open files in the process</td> </tr> <tr> <td>ENAMETOOLONG</td> <td>Name too long</td> </tr> <tr> <td>ENFILE</td> <td>Too many open files on the system</td> </tr> <tr> <td>ENOENT</td> <td>No such file or directory</td> </tr> <tr> <td>ENOMEM</td> <td>Cannot allocate memory</td> </tr> <tr> <td>ENOSPC</td> <td>No space on device</td> </tr> <tr> <td>ENOTDIR</td> <td>Is not a directory</td> </tr> <tr> <td>ENXIO</td> <td>Device no configured or does not support operation</td> </tr> <tr> <td>EOPNOTSUPP</td> <td>Operation not supported.<br> <span style="color:#a9a9a9;">May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.</span></td> </tr> <tr> <td>EOVERFLOW</td> <td>Value too large to be stored in datatype.<br> <span style="color:#a9a9a9;">May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.</span></td> </tr> <tr> <td>EPERM</td> <td>Operation not permitted</td> </tr> <tr> <td>ERANGE</td> <td>Result too large</td> </tr> <tr> <td>ETIMEDOUT</td> <td>Operation timed out.<br> <span style="color:#a9a9a9;">May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.</span></td> </tr> <tr> <td>EWOULDBLOCK</td> <td>Operation would block.<br> <span style="color:#a9a9a9;">May not be available under Windows for old versions of Firefox or custom versions of Firefox compiled with VC9 or older.</span></td> </tr> <tr> <td>EXDEV</td> <td>Cross-device link</td> </tr> </tbody>
</table>
<h3>Opening files<a name="libc_opening_files"></a></h3><a name="libc_opening_files">
<h4>Unix access rights.</h4>
<p>Defined on all platforms but meaningful only on Unix.</p>
<table border="1" cellpadding="1" cellspacing="1" style="table-layout: fixed;"> <tbody> <tr> <td>S_IRWXU</td> <td>Current User can Read, Write, eXecute the file. Equivalent to <code>S_IRUSR | S_IWUSR | S_IXUSR</code>.</td> </tr> <tr> <td>S_IRUSR</td> <td>Current User can Read the file.</td> </tr> <tr> <td>S_IWUSR</td> <td>Current User can Write (modify) the file.</td> </tr> <tr> <td>S_IXUSR</td> <td>Current User can eXecute the file.</td> </tr> <tr> <td>S_IRWXG</td> <td>Current GRouP of the current user can Read, Write, eXecute the file. Equivalent to <code>S_IRGRP | S_IWGRP | S_IXGRP</code>.</td> </tr> <tr> <td>S_IRGRP</td> <td>Current GRouP of the current user can Read the file.</td> </tr> <tr> <td>S_IWGRP</td> <td>Current GRouP of the current user can Write (modify) the file.</td> </tr> <tr> <td>S_IXGRP</td> <td>Current GRouP of the current user can eXecute the file.</td> </tr> <tr> <td>S_IRWXO</td> <td>All Other users can Read, Write, eXecute the file. Equivalent to <code>S_IROTH | S_IWOTH | S_IXOTH</code>.</td> </tr> <tr> <td>S_IROTH</td> <td>All Other users can Read the file.</td> </tr> <tr> <td>S_IWOTH</td> <td>All Other users can Write (modify) the file.</td> </tr> <tr> <td>S_IXOTH</td> <td>All Other users can eXecute the file.</td> </tr> </tbody>
</table>
<h4>Unix opening mode</h4>
<table border="1" cellpadding="1" cellspacing="1" style="table-layout: fixed;"> <tbody> <tr> <td>O_APPEND</td> <td>Open the file for appending.</td> </tr> <tr> <td>O_CREAT</td> <td>Create the file if it does not exist yet.</td> </tr> <tr> <td>O_DIRECTORY</td> <td><span style="color:#d3d3d3;">(Linux only)</span> Succeed only of the file is a directory.</td> </tr> <tr> <td>O_EVTONLY</td> <td>Descriptor requested for event notifications only.</td> </tr> <tr> <td>O_EXCL</td> <td>Raise an error if O_CREAT is set and the file exists.</td> </tr> <tr> <td>O_EXLOCK</td> <td>Atomically obtain an exclusive lock.</td> </tr> <tr> <td>O_LARGEFILE</td> <td> </td> </tr> <tr> <td>O_NOFOLLOW</td> <td>Do not follow symbolic links.</td> </tr> <tr> <td>O_NONBLOCK</td> <td>Do not block on open or for data to become available.</td> </tr> <tr> <td>O_RDONLY</td> <td>Open the file for read only.</td> </tr> <tr> <td>O_RDWR</td> <td>Open the file for read and write.</td> </tr> <tr> <td>O_RSYNC</td> <td> </td> </tr> <tr> <td>O_SHLOCK</td> <td>Atomically obtain a shared lock.</td> </tr> <tr> <td>O_SYMLINK</td> <td>Allow opening of symbolic links.</td> </tr> <tr> <td>O_SYNC</td> <td><span style="color:#d3d3d3;">(Linux only)</span> Open for purely synchronous access.</td> </tr> <tr> <td>O_TRUNC</td> <td>Truncate the file.</td> </tr> <tr> <td>O_WRONLY</td> <td>Open the file for write only.</td> </tr> </tbody>
</table>
<h2>OS.Constants.Win</h2>
</a><p><a name="libc_opening_files">Constants for interacting with the Windows API. <code>OS.Constants.Win</code> is <code>undefined</code> on non-Windows platforms. Useful mostly in conjunction with </a><a href="/en/js-ctypes" title="en/js-ctypes">js-ctypes</a>.</p>
<p>(tbd)</p>
Revert to this revision