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 ;
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 username 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.unix.files kernel ;"
94 "\"resource:license.txt\" OCT: 755 set-file-permissions"
97 "Higher-level, setting named bits:"
98 { $unchecked-example "USING: io.unix.files 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 username." } ;
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 { $subsection file-permissions }
219 "Reading individual file permissions:"
222 { $subsection sticky? }
223 { $subsection user-read? }
224 { $subsection user-write? }
225 { $subsection user-execute? }
226 { $subsection group-read? }
227 { $subsection group-write? }
228 { $subsection group-execute? }
229 { $subsection other-read? }
230 { $subsection other-write? }
231 { $subsection other-execute? }
232 "Writing all file permissions:"
233 { $subsection set-file-permissions }
234 "Writing individual file permissions:"
235 { $subsection set-uid }
236 { $subsection set-gid }
237 { $subsection set-sticky }
238 { $subsection set-user-read }
239 { $subsection set-user-write }
240 { $subsection set-user-execute }
241 { $subsection set-group-read }
242 { $subsection set-group-write }
243 { $subsection set-group-execute }
244 { $subsection set-other-read }
245 { $subsection set-other-write }
246 { $subsection set-other-execute } ;
248 ARTICLE: "unix-file-timestamps" "Unix file timestamps"
249 "To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
250 "Setting multiple file times:"
251 { $subsection set-file-times }
252 "Setting just the last access time:"
253 { $subsection set-file-access-time }
254 "Setting just the last modified time:"
255 { $subsection set-file-modified-time } ;
258 ARTICLE: "unix-file-ids" "Unix file user and group ids"
259 "Reading file user data:"
260 { $subsection file-user-id }
261 { $subsection file-username }
262 "Setting file user data:"
263 { $subsection set-file-user }
264 "Reading file group data:"
265 { $subsection file-group-id }
266 { $subsection file-group-name }
267 "Setting file group data:"
268 { $subsection set-file-group } ;
271 ARTICLE: "io.unix.files" "Unix file attributes"
272 "The " { $vocab-link "io.unix.files" } " vocabulary implements the Unix backend for opening files and provides a high-level way to set permissions, timestamps, and user and group ids for files."
273 { $subsection "unix-file-permissions" }
274 { $subsection "unix-file-timestamps" }
275 { $subsection "unix-file-ids" } ;
277 ABOUT: "io.unix.files"