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 ;
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. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
104 { $examples "Using the tradidional octal value:"
105 { $unchecked-example "USING: io.files.info.unix kernel ;"
106 "\"resource:license.txt\" OCT: 755 set-file-permissions"
109 "Higher-level, setting named bits:"
110 { $unchecked-example "USING: io.files.info.unix kernel literals ;"
111 "\"resource:license.txt\""
112 "flags{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
113 "set-file-permissions"
119 { "path" "a pathname string" } { "timestamps" "an array of two timestamps" } }
120 { $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." } ;
124 { "path" "a pathname string" } { "string/id" "a string or a user id" } }
125 { $description "Sets a file's user id from the given user id or user-name." } ;
127 HELP: set-file-modified-time
129 { "path" "a pathname string" } { "timestamp" timestamp } }
130 { $description "Sets a file's last modified timestamp, or write timestamp." } ;
134 { "path" "a pathname string" } { "?" "a boolean" } }
135 { $description "Sets the " { $snippet "gid" } " bit of a file to true or false." } ;
139 { "obj" "a pathname string, file-info object, or an integer" }
140 { "?" "a boolean" } }
141 { $description "Tests whether the " { $snippet "gid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
143 HELP: set-group-execute
145 { "path" "a pathname string" } { "?" "a boolean" } }
146 { $description "Sets the " { $snippet "group execute" } " bit of a file to true or false." } ;
150 { "path" "a pathname string" } { "?" "a boolean" } }
151 { $description "Sets the " { $snippet "group read" } " bit of a file to true or false." } ;
153 HELP: set-group-write
155 { "path" "a pathname string" } { "?" "a boolean" } }
156 { $description "Sets the " { $snippet "group write" } " bit of a file to true or false." } ;
158 HELP: set-other-execute
160 { "path" "a pathname string" } { "?" "a boolean" } }
161 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
165 { "path" "a pathname string" } { "?" "a boolean" } }
166 { $description "Sets the " { $snippet "other read" } " bit of a file to true or false." } ;
168 HELP: set-other-write
170 { "path" "a pathname string" } { "?" "a boolean" } }
171 { $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
175 { "path" "a pathname string" } { "?" "a boolean" } }
176 { $description "Sets the " { $snippet "sticky" } " bit of a file to true or false." } ;
180 { "obj" "a pathname string, file-info object, or an integer" }
181 { "?" "a boolean" } }
182 { $description "Tests whether the " { $snippet "sticky" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
186 { "path" "a pathname string" } { "?" "a boolean" } }
187 { $description "Sets the " { $snippet "uid" } " bit of a file to true or false." } ;
191 { "obj" "a pathname string, file-info object, or an integer" }
192 { "?" "a boolean" } }
193 { $description "Tests whether the " { $snippet "uid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
195 HELP: set-user-execute
197 { "path" "a pathname string" } { "?" "a boolean" } }
198 { $description "Sets the " { $snippet "user execute" } " bit of a file to true or false." } ;
202 { "path" "a pathname string" } { "?" "a boolean" } }
203 { $description "Sets the " { $snippet "user read" } " bit of a file to true or false." } ;
207 { "path" "a pathname string" } { "?" "a boolean" } }
208 { $description "Sets the " { $snippet "user write" } " bit of a file to true or false." } ;
212 { "obj" "a pathname string, file-info object, or an integer" }
213 { "?" "a boolean" } }
214 { $description "Tests whether the " { $snippet "user execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
218 { "obj" "a pathname string, file-info object, or an integer" }
219 { "?" "a boolean" } }
220 { $description "Tests whether the " { $snippet "user read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
224 { "obj" "a pathname string, file-info object, or an integer" }
225 { "?" "a boolean" } }
226 { $description "Tests whether the " { $snippet "user write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
228 ARTICLE: "unix-file-permissions" "Unix file permissions"
229 "Reading all file permissions:"
230 { $subsections file-permissions }
231 "Reading individual file permissions:"
246 "Changing file permissions:"
249 remove-file-permissions
252 "Writing individual file permissions:"
268 ARTICLE: "unix-file-timestamps" "Unix file timestamps"
269 "To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
270 "Setting multiple file times:"
271 { $subsections set-file-times }
272 "Setting just the last access time:"
273 { $subsections set-file-access-time }
274 "Setting just the last modified time:"
275 { $subsections set-file-modified-time } ;
278 ARTICLE: "unix-file-ids" "Unix file user and group ids"
279 "Reading file user data:"
284 "Setting file user data:"
285 { $subsections set-file-user }
286 "Reading file group data:"
291 "Setting file group data:"
292 { $subsections set-file-group } ;
295 ARTICLE: "io.files.info.unix" "Unix file attributes"
296 "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."
298 "unix-file-permissions"
299 "unix-file-timestamps"
303 ABOUT: "io.files.info.unix"