1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: calendar help.markup help.syntax io.files.info kernel
7 HELP: add-file-permissions
9 { "path" "a pathname string" }
11 { $description "Ensures that the bits from " { $snippet "n" } " are set in the Unix file permissions for a given file." } ;
13 HELP: remove-file-permissions
15 { "path" "a pathname string" }
17 { $description "Ensures that the bits from " { $snippet "n" } " are cleared in the Unix file permissions for a given file." } ;
21 { "path" "a pathname string" }
23 { $description "Returns the group id for a given file." } ;
27 { "path" "a pathname string" }
29 { $description "Returns the group name for a given file." } ;
31 HELP: file-permissions
33 { "path" "a pathname string" }
35 { $description "Returns the Unix file permissions for a given file." } ;
39 { "path" "a pathname string" }
41 { $description "Returns the user-name for a given file." } ;
45 { "path" "a pathname string" }
47 { $description "Returns the user id for a given file." } ;
51 { "obj" "a pathname string or an integer" }
53 { $description "Tests whether the " { $snippet "group execute" } " 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 "group read" } " 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 "group write" } " 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 execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
75 { "obj" "a pathname string, file-info object, or an integer" }
77 { $description "Tests whether the " { $snippet "other read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
81 { "obj" "a pathname string, file-info object, or an integer" }
83 { $description "Tests whether the " { $snippet "other write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
85 HELP: set-file-access-time
87 { "path" "a pathname string" } { "timestamp" timestamp } }
88 { $description "Sets a file's last access timestamp." } ;
92 { "path" "a pathname string" } { "string/id" "a string or a group id" } }
93 { $description "Sets a file's group id from the given group id or group name." } ;
97 { "path" "a pathname string" } { "uid" integer } { "gid" integer } }
98 { $description "Sets the user id and group id of a file with a single library call." } ;
100 HELP: set-file-permissions
102 { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
103 { $description "Sets the file permissions for a given file with the supplied Unix permissions integer." }
104 { $examples "Using the traditional octal value:"
105 { $code "USING: io.files.info.unix kernel ;"
106 "\"resource:LICENSE.txt\" 0o755 set-file-permissions"
108 "Higher-level, setting named bits:"
109 { $code "USING: io.files.info.unix kernel literals ;"
110 "\"resource:LICENSE.txt\""
111 "flags{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
112 "set-file-permissions"
118 { "path" "a pathname string" } { "timestamps" "an array of two timestamps" } }
119 { $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." } ;
123 { "path" "a pathname string" } { "string/id" "a string or a user id" } }
124 { $description "Sets a file's user id from the given user id or user-name." } ;
126 HELP: set-file-modified-time
128 { "path" "a pathname string" } { "timestamp" timestamp } }
129 { $description "Sets a file's last modified timestamp, or write timestamp." } ;
133 { "path" "a pathname string" } { "?" boolean } }
134 { $description "Sets the " { $snippet "gid" } " bit of a file to true or false." } ;
138 { "obj" "a pathname string, file-info object, or an integer" }
140 { $description "Tests whether the " { $snippet "gid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
142 HELP: set-group-execute
144 { "path" "a pathname string" } { "?" boolean } }
145 { $description "Sets the " { $snippet "group execute" } " bit of a file to true or false." } ;
149 { "path" "a pathname string" } { "?" boolean } }
150 { $description "Sets the " { $snippet "group read" } " bit of a file to true or false." } ;
152 HELP: set-group-write
154 { "path" "a pathname string" } { "?" boolean } }
155 { $description "Sets the " { $snippet "group write" } " bit of a file to true or false." } ;
157 HELP: set-other-execute
159 { "path" "a pathname string" } { "?" boolean } }
160 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
164 { "path" "a pathname string" } { "?" boolean } }
165 { $description "Sets the " { $snippet "other read" } " bit of a file to true or false." } ;
167 HELP: set-other-write
169 { "path" "a pathname string" } { "?" boolean } }
170 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
174 { "path" "a pathname string" } { "?" boolean } }
175 { $description "Sets the " { $snippet "sticky" } " bit of a file to true or false." } ;
179 { "obj" "a pathname string, file-info object, or an integer" }
181 { $description "Tests whether the " { $snippet "sticky" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
185 { "path" "a pathname string" } { "?" boolean } }
186 { $description "Sets the " { $snippet "uid" } " bit of a file to true or false." } ;
190 { "obj" "a pathname string, file-info object, or an integer" }
192 { $description "Tests whether the " { $snippet "uid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
194 HELP: set-user-execute
196 { "path" "a pathname string" } { "?" boolean } }
197 { $description "Sets the " { $snippet "user execute" } " bit of a file to true or false." } ;
201 { "path" "a pathname string" } { "?" boolean } }
202 { $description "Sets the " { $snippet "user read" } " bit of a file to true or false." } ;
206 { "path" "a pathname string" } { "?" boolean } }
207 { $description "Sets the " { $snippet "user write" } " bit of a file to true or false." } ;
211 { "obj" "a pathname string, file-info object, or an integer" }
213 { $description "Tests whether the " { $snippet "user execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
217 { "obj" "a pathname string, file-info object, or an integer" }
219 { $description "Tests whether the " { $snippet "user read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
223 { "obj" "a pathname string, file-info object, or an integer" }
225 { $description "Tests whether the " { $snippet "user write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
227 ARTICLE: "unix-file-permissions" "Unix file permissions"
228 "Reading all file permissions:"
229 { $subsections file-permissions }
230 "Reading individual file permissions:"
245 "Changing file permissions:"
248 remove-file-permissions
251 "Writing individual file permissions:"
267 ARTICLE: "unix-file-timestamps" "Unix file timestamps"
268 "To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
269 "Setting multiple file times:"
270 { $subsections set-file-times }
271 "Setting just the last access time:"
272 { $subsections set-file-access-time }
273 "Setting just the last modified time:"
274 { $subsections set-file-modified-time } ;
277 ARTICLE: "unix-file-ids" "Unix file user and group ids"
278 "Reading file user data:"
283 "Setting file user data:"
284 { $subsections set-file-user }
285 "Reading file group data:"
290 "Setting file group data:"
291 { $subsections set-file-group } ;
294 ARTICLE: "io.files.info.unix" "Unix file attributes"
295 "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."
297 "unix-file-permissions"
298 "unix-file-timestamps"
302 ABOUT: "io.files.info.unix"