44
55import cpp
66
7+ /**
8+ * Gets the number corresponding to the contents of `input` in base-8.
9+ * Note: the first character of `input` must be `0`. For example:
10+ * `parseOctal("012345") = 5349`.
11+ */
712bindingset [ input]
813int parseOctal ( string input ) {
914 input .charAt ( 0 ) = "0" and
@@ -15,44 +20,77 @@ int parseOctal(string input) {
1520 )
1621}
1722
23+ /** Gets the number corresponding to the "set-user-ID on execute bit" in Unix. */
1824int s_isuid ( ) { result = parseOctal ( "04000" ) }
1925
26+ /** Gets the number corresponding to the "set-group-ID on execute bit" in Unix. */
2027int s_isgid ( ) { result = parseOctal ( "02000" ) }
2128
29+ /** Gets the number corresponding to the sticky bit in Unix. */
2230int s_isvtx ( ) { result = parseOctal ( "01000" ) }
2331
32+ /** Gets the number corresponding to the read permission bit for owner of the file in Unix. */
2433int s_irusr ( ) { result = parseOctal ( "0400" ) }
2534
35+ /** Gets the number corresponding to the write permission bit for owner of the file in Unix. */
2636int s_iwusr ( ) { result = parseOctal ( "0200" ) }
2737
38+ /** Gets the number corresponding to the execute permission bit for owner of the file in Unix. */
2839int s_ixusr ( ) { result = parseOctal ( "0100" ) }
2940
41+ /** Gets the number corresponding to the permissions `S_IRUSR | S_IWUSR | S_IXUSR` in Unix. */
3042int s_irwxu ( ) { result = s_irusr ( ) .bitOr ( s_iwusr ( ) ) .bitOr ( s_ixusr ( ) ) }
3143
44+ /**
45+ * Gets the number corresponding to the read permission bit for the group
46+ * owner of the file in Unix.
47+ */
3248int s_irgrp ( ) { result = s_irusr ( ) .bitShiftRight ( 3 ) }
3349
50+ /**
51+ * Gets the number corresponding to the write permission bit for the group
52+ * owner of the file in Unix.
53+ */
3454int s_iwgrp ( ) { result = s_iwusr ( ) .bitShiftRight ( 3 ) }
3555
56+ /**
57+ * Gets the number corresponding to the execute permission bit for the group
58+ * owner of the file in Unix.
59+ */
3660int s_ixgrp ( ) { result = s_ixusr ( ) .bitShiftRight ( 3 ) }
3761
62+ /** Gets the number corresponding to the permissions `S_IRGRP | S_IWGRP | S_IXGRP` in Unix. */
3863int s_irwxg ( ) { result = s_irwxu ( ) .bitShiftRight ( 3 ) }
3964
65+ /** Gets the number corresponding to the read permission bit for other users in Unix. */
4066int s_iroth ( ) { result = s_irgrp ( ) .bitShiftRight ( 3 ) }
4167
68+ /** Gets the number corresponding to the write permission bit for other users in Unix. */
4269int s_iwoth ( ) { result = s_iwgrp ( ) .bitShiftRight ( 3 ) }
4370
71+ /** Gets the number corresponding to the execute-or-search permission bit for other users in Unix. */
4472int s_ixoth ( ) { result = s_ixgrp ( ) .bitShiftRight ( 3 ) }
4573
74+ /** Gets the number corresponding to the permissions `S_IROTH | S_IWOTH | S_IXOTH` in Unix. */
4675int s_irwxo ( ) { result = s_irwxg ( ) .bitShiftRight ( 3 ) }
4776
77+ /**
78+ * Gets the number that can be used in a bitwise and with the file status flag
79+ * to produce a number representing the file access mode.
80+ */
4881int o_accmode ( ) { result = parseOctal ( "0003" ) }
4982
83+ /** Gets the number corresponding to the read-only file access mode. */
5084int o_rdonly ( ) { result = parseOctal ( "00" ) }
5185
86+ /** Gets the number corresponding to the write-only file access mode. */
5287int o_wronly ( ) { result = parseOctal ( "01" ) }
5388
89+ /** Gets the number corresponding to the read-and-write file access mode. */
5490int o_rdwr ( ) { result = parseOctal ( "02" ) }
5591
92+ /** Gets the number corresponding to the file creation flag O_CREAT on Linux. */
5693int o_creat ( ) { result = parseOctal ( "0100" ) }
5794
95+ /** Gets the number corresponding to the file creation flag O_EXCL on Linux. */
5896int o_excl ( ) { result = parseOctal ( "0200" ) }
0 commit comments