MCPcopy Index your code
hub / github.com/nodejs/node / stringToFlags

Function stringToFlags

lib/internal/fs/utils.js:726–767  ·  view source on GitHub ↗
(flags, name = 'flags')

Source from the content-addressed store, hash-verified

724}
725
726function stringToFlags(flags, name = 'flags') {
727 if (typeof flags === 'number') {
728 validateInt32(flags, name);
729 // Coerce -0 to +0.
730 return flags + 0;
731 }
732
733 if (flags == null) {
734 return O_RDONLY;
735 }
736
737 switch (flags) {
738 case 'r' : return O_RDONLY;
739 case 'rs' : // Fall through.
740 case 'sr' : return O_RDONLY | O_SYNC;
741 case 'r+' : return O_RDWR;
742 case 'rs+' : // Fall through.
743 case 'sr+' : return O_RDWR | O_SYNC;
744
745 case 'w' : return O_TRUNC | O_CREAT | O_WRONLY;
746 case 'wx' : // Fall through.
747 case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;
748
749 case 'w+' : return O_TRUNC | O_CREAT | O_RDWR;
750 case 'wx+': // Fall through.
751 case 'xw+': return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;
752
753 case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
754 case 'ax' : // Fall through.
755 case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;
756 case 'as' : // Fall through.
757 case 'sa' : return O_APPEND | O_CREAT | O_WRONLY | O_SYNC;
758
759 case 'a+' : return O_APPEND | O_CREAT | O_RDWR;
760 case 'ax+': // Fall through.
761 case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL;
762 case 'as+': // Fall through.
763 case 'sa+': return O_APPEND | O_CREAT | O_RDWR | O_SYNC;
764 }
765
766 throw new ERR_INVALID_ARG_VALUE('flags', flags);
767}
768
769const stringToSymlinkType = hideStackFrames((type) => {
770 switch (type) {

Callers 8

readFileFunction · 0.85
readFileSyncFunction · 0.85
openFunction · 0.85
openSyncFunction · 0.85
writeFileSyncFunction · 0.85
openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…