1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: classes help.markup help.syntax io.streams.string
4 strings math calendar io.files.info io.files.info.unix ;
9 { "path" "a pathname string" }
11 { $description "Returns the group id for a given file." } ;
15 { "path" "a pathname string" }
17 { $description "Returns the group name for a given file." } ;
19 HELP: file-permissions
21 { "path" "a pathname string" }
23 { $description "Returns the Unix file permissions for a given file." } ;
27 { "path" "a pathname string" }
29 { $description "Returns the user-name for a given file." } ;
33 { "path" "a pathname string" }
35 { $description "Returns the user id for a given file." } ;
39 { "obj" "a pathname string or an integer" }
41 { $description "Tests whether the " { $snippet "group execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
45 { "obj" "a pathname string, file-info object, or an integer" }
47 { $description "Tests whether the " { $snippet "group read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
51 { "obj" "a pathname string, file-info object, or an integer" }
53 { $description "Tests whether the " { $snippet "group write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
57 { "obj" "a pathname string, file-info object, or an integer" }
59 { $description "Tests whether the " { $snippet "other execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
63 { "obj" "a pathname string, file-info object, or an integer" }
65 { $description "Tests whether the " { $snippet "other read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
69 { "obj" "a pathname string, file-info object, or an integer" }
71 { $description "Tests whether the " { $snippet "other write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
73 HELP: set-file-access-time
75 { "path" "a pathname string" } { "timestamp" timestamp } }
76 { $description "Sets a file's last access timestamp." } ;
80 { "path" "a pathname string" } { "string/id" "a string or a group id" } }
81 { $description "Sets a file's group id from the given group id or group name." } ;
85 { "path" "a pathname string" } { "uid" integer } { "gid" integer } }
86 { $description "Sets the user id and group id of a file with a single library call." } ;
88 HELP: set-file-permissions
90 { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
91 { $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
92 { $examples "Using the tradidional octal value:"
93 { $unchecked-example "USING: io.files.unix kernel ;"
94 "\"resource:license.txt\" OCT: 755 set-file-permissions"
97 "Higher-level, setting named bits:"
98 { $unchecked-example "USING: io.files.unix kernel math.bitwise ;"
99 "\"resource:license.txt\""
100 "{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
101 "flags set-file-permissions"
107 { "path" "a pathname string" } { "timestamps" "an array of two timestamps" } }
108 { $description "Sets the access and write timestamps for a file as provided in the input array. A value of " { $link f } " provided for either of the timestamps will not change that timestamp." } ;
112 { "path" "a pathname string" } { "string/id" "a string or a user id" } }
113 { $description "Sets a file's user id from the given user id or user-name." } ;
115 HELP: set-file-modified-time
117 { "path" "a pathname string" } { "timestamp" timestamp } }
118 { $description "Sets a file's last modified timestamp, or write timestamp." } ;
122 { "path" "a pathname string" } { "?" "a boolean" } }
123 { $description "Sets the " { $snippet "gid" } " bit of a file to true or false." } ;
127 { "obj" "a pathname string, file-info object, or an integer" }
128 { "?" "a boolean" } }
129 { $description "Tests whether the " { $snippet "gid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
131 HELP: set-group-execute
133 { "path" "a pathname string" } { "?" "a boolean" } }
134 { $description "Sets the " { $snippet "group execute" } " bit of a file to true or false." } ;
138 { "path" "a pathname string" } { "?" "a boolean" } }
139 { $description "Sets the " { $snippet "group read" } " bit of a file to true or false." } ;
141 HELP: set-group-write
143 { "path" "a pathname string" } { "?" "a boolean" } }
144 { $description "Sets the " { $snippet "group write" } " bit of a file to true or false." } ;
146 HELP: set-other-execute
148 { "path" "a pathname string" } { "?" "a boolean" } }
149 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
153 { "path" "a pathname string" } { "?" "a boolean" } }
154 { $description "Sets the " { $snippet "other read" } " bit of a file to true or false." } ;
156 HELP: set-other-write
158 { "path" "a pathname string" } { "?" "a boolean" } }
159 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
163 { "path" "a pathname string" } { "?" "a boolean" } }
164 { $description "Sets the " { $snippet "sticky" } " bit of a file to true or false." } ;
168 { "obj" "a pathname string, file-info object, or an integer" }
169 { "?" "a boolean" } }
170 { $description "Tests whether the " { $snippet "sticky" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
174 { "path" "a pathname string" } { "?" "a boolean" } }
175 { $description "Sets the " { $snippet "uid" } " bit of a file to true or false." } ;
179 { "obj" "a pathname string, file-info object, or an integer" }
180 { "?" "a boolean" } }
181 { $description "Tests whether the " { $snippet "uid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
183 HELP: set-user-execute
185 { "path" "a pathname string" } { "?" "a boolean" } }
186 { $description "Sets the " { $snippet "user execute" } " bit of a file to true or false." } ;
190 { "path" "a pathname string" } { "?" "a boolean" } }
191 { $description "Sets the " { $snippet "user read" } " bit of a file to true or false." } ;
195 { "path" "a pathname string" } { "?" "a boolean" } }
196 { $description "Sets the " { $snippet "user write" } " bit of a file to true or false." } ;
200 { "obj" "a pathname string, file-info object, or an integer" }
201 { "?" "a boolean" } }
202 { $description "Tests whether the " { $snippet "user execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
206 { "obj" "a pathname string, file-info object, or an integer" }
207 { "?" "a boolean" } }
208 { $description "Tests whether the " { $snippet "user read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
212 { "obj" "a pathname string, file-info object, or an integer" }
213 { "?" "a boolean" } }
214 { $description "Tests whether the " { $snippet "user write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
216 ARTICLE: "unix-file-permissions" "Unix file permissions"
217 "Reading all file permissions:"
218 { $subsections file-permissions }
219 "Reading individual file permissions:"
234 "Writing all file permissions:"
235 { $subsections set-file-permissions }
236 "Writing individual file permissions:"
252 ARTICLE: "unix-file-timestamps" "Unix file timestamps"
253 "To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
254 "Setting multiple file times:"
255 { $subsections set-file-times }
256 "Setting just the last access time:"
257 { $subsections set-file-access-time }
258 "Setting just the last modified time:"
259 { $subsections set-file-modified-time } ;
262 ARTICLE: "unix-file-ids" "Unix file user and group ids"
263 "Reading file user data:"
268 "Setting file user data:"
269 { $subsections set-file-user }
270 "Reading file group data:"
275 "Setting file group data:"
276 { $subsections set-file-group } ;
279 ARTICLE: "io.files.info.unix" "Unix file attributes"
280 "The " { $vocab-link "io.files.info.unix" } " vocabulary implements a high-level way to set Unix-specific permissions, timestamps, and user and group IDs for files."
282 "unix-file-permissions"
283 "unix-file-timestamps"
287 ABOUT: "io.files.info.unix"