Method description:
Synchronized version of fs.open() .
Grammar:
fs.openSync(path, flags, [mode])
Since this method belongs to the fs module, the fs module needs to be introduced before use (var fs= require(“fs”) )
Receive parameters:
path File path
flags can be the following values
'r' - Open the file in read mode.
'r ' - Open the file in read-write mode.
'rs' - Open and read the file using synchronous mode. Instructs the operating system to ignore the local file system cache.
'rs ' - Open, read and write the file synchronously.
'w' - Open the file in read mode or create it if it does not exist
'wx' - same as ' w ' mode, returns failure if the file exists
'w ' - Open the file in read-write mode, create the file if it does not exist
'wx ' - same as ' w ' mode, returns failure if the file exists
'a' - Open the file in append mode, creating it if it does not exist
'ax' - same as ' a ' mode, returns failure if the file exists
'a ' - Open file in read-append mode, create if file does not exist
'ax ' - same as ' a ' mode, returns failure if the file exists
mode is used to set permissions for files when creating files. The default is 0666
Source code:
fs.openSync = function(path, flags, mode) {
mode = modeNum(mode, 438 /*=0666*/);
nullCheck(path);
Return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
};