57 lines
3.0 KiB
JavaScript
57 lines
3.0 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.FLAGS = exports.ERRSTR = void 0;
|
||
|
const constants_1 = require("../constants");
|
||
|
exports.ERRSTR = {
|
||
|
PATH_STR: 'path must be a string or Buffer',
|
||
|
// FD: 'file descriptor must be a unsigned 32-bit integer',
|
||
|
FD: 'fd must be a file descriptor',
|
||
|
MODE_INT: 'mode must be an int',
|
||
|
CB: 'callback must be a function',
|
||
|
UID: 'uid must be an unsigned int',
|
||
|
GID: 'gid must be an unsigned int',
|
||
|
LEN: 'len must be an integer',
|
||
|
ATIME: 'atime must be an integer',
|
||
|
MTIME: 'mtime must be an integer',
|
||
|
PREFIX: 'filename prefix is required',
|
||
|
BUFFER: 'buffer must be an instance of Buffer or StaticBuffer',
|
||
|
OFFSET: 'offset must be an integer',
|
||
|
LENGTH: 'length must be an integer',
|
||
|
POSITION: 'position must be an integer',
|
||
|
};
|
||
|
const { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_SYNC } = constants_1.constants;
|
||
|
// List of file `flags` as defined by Node.
|
||
|
var FLAGS;
|
||
|
(function (FLAGS) {
|
||
|
// Open file for reading. An exception occurs if the file does not exist.
|
||
|
FLAGS[FLAGS["r"] = O_RDONLY] = "r";
|
||
|
// Open file for reading and writing. An exception occurs if the file does not exist.
|
||
|
FLAGS[FLAGS["r+"] = O_RDWR] = "r+";
|
||
|
// Open file for reading in synchronous mode. Instructs the operating system to bypass the local file system cache.
|
||
|
FLAGS[FLAGS["rs"] = O_RDONLY | O_SYNC] = "rs";
|
||
|
FLAGS[FLAGS["sr"] = FLAGS.rs] = "sr";
|
||
|
// Open file for reading and writing, telling the OS to open it synchronously. See notes for 'rs' about using this with caution.
|
||
|
FLAGS[FLAGS["rs+"] = O_RDWR | O_SYNC] = "rs+";
|
||
|
FLAGS[FLAGS["sr+"] = FLAGS['rs+']] = "sr+";
|
||
|
// Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
|
||
|
FLAGS[FLAGS["w"] = O_WRONLY | O_CREAT | O_TRUNC] = "w";
|
||
|
// Like 'w' but fails if path exists.
|
||
|
FLAGS[FLAGS["wx"] = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL] = "wx";
|
||
|
FLAGS[FLAGS["xw"] = FLAGS.wx] = "xw";
|
||
|
// Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
|
||
|
FLAGS[FLAGS["w+"] = O_RDWR | O_CREAT | O_TRUNC] = "w+";
|
||
|
// Like 'w+' but fails if path exists.
|
||
|
FLAGS[FLAGS["wx+"] = O_RDWR | O_CREAT | O_TRUNC | O_EXCL] = "wx+";
|
||
|
FLAGS[FLAGS["xw+"] = FLAGS['wx+']] = "xw+";
|
||
|
// Open file for appending. The file is created if it does not exist.
|
||
|
FLAGS[FLAGS["a"] = O_WRONLY | O_APPEND | O_CREAT] = "a";
|
||
|
// Like 'a' but fails if path exists.
|
||
|
FLAGS[FLAGS["ax"] = O_WRONLY | O_APPEND | O_CREAT | O_EXCL] = "ax";
|
||
|
FLAGS[FLAGS["xa"] = FLAGS.ax] = "xa";
|
||
|
// Open file for reading and appending. The file is created if it does not exist.
|
||
|
FLAGS[FLAGS["a+"] = O_RDWR | O_APPEND | O_CREAT] = "a+";
|
||
|
// Like 'a+' but fails if path exists.
|
||
|
FLAGS[FLAGS["ax+"] = O_RDWR | O_APPEND | O_CREAT | O_EXCL] = "ax+";
|
||
|
FLAGS[FLAGS["xa+"] = FLAGS['ax+']] = "xa+";
|
||
|
})(FLAGS || (exports.FLAGS = FLAGS = {}));
|
||
|
//# sourceMappingURL=constants.js.map
|