root/tags/lgt2210/library/systemp.lgt

Revision 1197, 14.5 KB (checked in by pmoura, 4 years ago)

Changes related to file names nomenculature.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- protocol(systemp).
3
4    :- info([
5        version is 1.9,
6        author is 'Portable Operating-System Interface (POSI) initiative',
7        date is 2004/7/27,
8        comment is 'Portable operating system access protocol.']).
9
10    :- public(make_directory/1).
11    :- mode(make_directory(+atom), one).
12    :- info(make_directory/1, [
13        comment is 'Makes a new directory.',
14        argnames is ['Directory'],
15        exceptions is [
16            'Directory is not instantiated' - instantiation_error,
17            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
18            'No permission for making a new directory' - permission_error(write, 'Directory')]]).
19
20    :- public(delete_directory/1).
21    :- mode(delete_directory(+atom), one).
22    :- info(delete_directory/1, [
23        comment is 'Deletes a directory (and all of its contents).',
24        argnames is ['Directory'],
25        exceptions is [
26            'Directory is not instantiated' - instantiation_error,
27            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
28            'No permission for deleting the directory' - permission_error(write, 'Directory'),
29            'Directory does not exists' - existence_error(directory, 'Directory')]]).
30
31    :- public(change_directory/1).
32    :- mode(change_directory(+atom), one).
33    :- info(change_directory/1, [
34        comment is 'Changes current working directory.',
35        argnames is ['Directory'],
36        exceptions is [
37            'Directory is not instantiated' - instantiation_error,
38            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
39            'No permission for accessing the directory' - permission_error(read, 'Directory'),
40            'Directory does not exists' - existence_error(directory, 'Directory')]]).
41
42    :- public(working_directory/1).
43    :- mode(working_directory(?atom), one).
44    :- info(working_directory/1, [
45        comment is 'Current working directory (as an absolute file name).',
46        argnames is ['Directory'],
47        exceptions is [
48            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]).
49
50    :- public(directory_exists/1).
51    :- mode(directory_exists(+atom), zero_or_one).
52    :- info(directory_exists/1, [
53        comment is 'True if the specified directory exists (irrespective of directory permissions).',
54        argnames is ['Directory'],
55        exceptions is [
56            'Directory is not instantiated' - instantiation_error,
57            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]).
58
59    :- public(directory_files/2).
60    :- mode(directory_files(+atom, -list), one).
61    :- info(directory_files/2, [
62        comment is 'List of all directory files (returns an empty list if the directory is empty).',
63        argnames is ['Directory', 'Files'],
64        exceptions is [
65            'Directory is not instantiated' - instantiation_error,
66            'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
67            'No read permission for the directory' - permission_error(read, 'Directory'),
68            'Directory does not exists' - existence_error(directory, 'Directory')]]).
69
70    :- public(delete_file/1).
71    :- mode(delete_file(+atom), one).
72    :- info(delete_file/1, [
73        comment is 'Deletes a file.',
74        argnames is ['File'],
75        exceptions is [
76            'File is not instantiated' - instantiation_error,
77            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
78            'File does not exists' - existence_error(file, 'File'),
79            'No write permission to the file' - permission_error(write, 'File')]]).
80
81    :- public(rename_file/2).
82    :- mode(rename_file(+atom, +atom), zero_or_one).
83    :- info(rename_file/2, [
84        comment is 'Renames a file (or a directory).',
85        argnames is ['Old', 'New'],
86        exceptions is [
87            'Old is not instantiated' - instantiation_error,
88            'New is not instantiated' - instantiation_error,
89            'Old is neither a variable nor a valid file name' - type_error(file_name, 'Old'),
90            'New is neither a variable nor a valid file name' - type_error(file_name, 'New'),
91            'File Old does not exists' - existence_error(file, 'Old'),
92            'No write permission to the file' - permission_error(write, 'Old')]]).
93
94    :- public(copy_file/2).
95    :- mode(copy_file(+atom, +atom), one).
96    :- info(copy_file/2, [
97        comment is 'Makes a copy of a file.',
98        argnames is ['Original', 'Copy'],
99        exceptions is [
100            'Original is not instantiated' - instantiation_error,
101            'Copy is not instantiated' - instantiation_error,
102            'Original is neither a variable nor a valid file name' - type_error(file_name, 'Original'),
103            'Copy is neither a variable nor a valid file name' - type_error(file_name, 'Copy'),
104            'File Original does not exists' - existence_error(file, 'Original'),
105            'No read permission to the original file' - permission_error(read, 'Original'),
106            'No write permission to the file copy' - permission_error(write, 'Copy')]]).
107
108    :- public(make_symlink/2).
109    :- mode(make_symlink(+atom, +atom), one).
110    :- info(make_symlink/2, [
111        comment is 'Makes a symbolic link.',
112        argnames is ['Symlink', 'Target'],
113        exceptions is [
114            'Symlink is not instantiated' - instantiation_error,
115            'Target is not instantiated' - instantiation_error,
116            'Symlink is neither a variable nor a valid file name' - type_error(file_name, 'Symlink'),
117            'Target is neither a variable nor a valid file name' - type_error(file_name, 'Target'),
118            'No permission for creating the symbolic link' - permission_error(write, 'Symlink')]]).
119
120    :- public(file_exists/1).
121    :- mode(file_exists(+atom), zero_or_one).
122    :- info(file_exists/1, [
123        comment is 'True if the specified file exists (irrespective of type and file permissions).',
124        argnames is ['File'],
125        exceptions is [
126            'File is not instantiated' - instantiation_error,
127            'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
128
129    :- public(file_property/2).
130    :- mode(file_property(+atom, +compound), zero_or_one).
131    :- mode(file_property(+atom, -compound), one_or_more).
132    :- info(file_property/2, [
133        comment is 'File properties.',
134        argnames is ['File', 'Property'],
135        exceptions is [
136            'File is not instantiated' - instantiation_error,
137            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
138            'File does not exists' - existence_error(file, 'File'),
139            'No read permission to the file' - permission_error(read, 'File'),
140            'Property is neither a variable nor a file property' - type_error(file_property, 'Property')]]).
141
142    :- public(current_environment_variable/1).
143    :- mode(current_environment_variable(?atom), zero_or_more).
144    :- info(current_environment_variable/1, [
145        comment is 'Argument is a currently defined environment variable . Fails if the variable does not exists.',
146        argnames is ['Variable'],
147        exceptions is [
148            'Variable is neither a variable nor an atom' - type_error(atom, 'Variable')]]).
149
150    :- public(delete_environment_variable/1).
151    :- mode(delete_environment_variable(+atom), one).
152    :- info(delete_environment_variable/1, [
153        comment is 'Deletes an environment variable.',
154        argnames is ['Variable'],
155        exceptions is [
156            'Variable is not instantiated' - instantiation_error,
157            'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
158            'Variable is not a currenttly defined environment variable' - existence_error(environment_variable, 'Variable')]]).
159
160    :- public(get_environment_variable/2).
161    :- mode(get_environment_variable(+atom, ?atom), zero_or_one).
162    :- info(get_environment_variable/2, [
163        comment is 'Gets environment variable value.',
164        argnames is ['Variable', 'Value'],
165        exceptions is [
166            'Variable is not instantiated' - instantiation_error,
167            'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
168            'Value is neither a variable nor an atom' - type_error(atom, 'Value'),
169            'Variable is not a currenttly defined environment variable' - existence_error(environment_variable, 'Variable')]]).
170
171    :- public(set_environment_variable/2).
172    :- mode(set_environment_variable(+atom, +atom), one).
173    :- info(set_environment_variable/2, [
174        comment is 'Sets environment variable value.',
175        argnames is ['Variable', 'Value'],
176        exceptions is [
177            'Variable is not instantiated' - instantiation_error,
178            'Value is not instantiated' - instantiation_error,
179            'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
180            'Value is neither a variable nor an atom' - type_error(atom, 'Value')]]).
181
182    :- public(time_stamp/1).
183    :- mode(time_stamp(-number), one).
184    :- info(time_stamp/1, [
185        comment is 'Returns a system-dependent time stamp (which can be used for sorting).',
186        argnames is ['Time']]).
187
188    :- public(local_time/1).
189    :- mode(local_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
190    :- info(local_time/1, [
191        comment is 'Local time (respecting time zone and daylight savings settings).',
192        argnames is [time('Year', 'Month', 'Day', 'Hours', 'Mins', 'Secs', 'Microsecs')]]).
193
194    :- public(utc_time/1).
195    :- mode(utc_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
196    :- info(utc_time/1, [
197        comment is 'Universal Coordinated Time (UTC).',
198        argnames is [time('Year', 'Month', 'Day', 'Hours', 'Mins', 'Secs', 'Microsecs')]]).
199
200    :- public(convert_time/2).
201    :- mode(convert_time(+number, ?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
202    :- mode(convert_time(?number, +time(+integer, +integer, +integer, +integer, +integer, +integer, +integer)), zero_or_one).
203    :- info(convert_time/2, [
204        comment is 'Converts between system-dependent time stamps and calendar local date and time.',
205        argnames is ['Time', time('Year', 'Month', 'Day', 'Hours', 'Mins', 'Secs', 'Microsecs')],
206        exceptions is [
207            'Neither argument is instantiated' - instantiation_error,
208            'Time stamp is neither a variable nor a valid time stamp' - type_error(time_stamp, 'Time'),
209            'Time structure is neither a variable nor a valid time structure' - type_error(time_structure, 'time(Year, Month, Day, Hours, Mins, Secs, Microsecs)')]]).
210
211    :- public(cpu_time/1).
212    :- mode(cpu_time(-number), one).
213    :- info(cpu_time/1, [
214        comment is 'System cpu time in seconds.',
215        argnames is ['Time']]).
216
217    :- public(host_name/1).
218    :- mode(host_name(-atom), one).
219    :- info(host_name/1, [
220        comment is 'Host name (default is localhost).',
221        argnames is ['Name']]).
222
223    :- public(portable_os_file_name/2).
224    :- mode(portable_os_file_name(+atom, -atom), one).
225    :- mode(portable_os_file_name(-atom, +atom), one).
226    :- info(portable_os_file_name/2, [
227        comment is 'Converts between portable and operating-system dependent file names.',
228        argnames is ['Canonical', 'OS']]).
229
230    :- public(portable_file_name/3).
231    :- mode(portable_file_name(+atom, -atom, -atom), one).
232    :- mode(portable_file_name(-atom, +atom, -atom), one).
233    :- mode(portable_file_name(-atom, -atom, +atom), one).
234    :- info(portable_file_name/3, [
235        comment is 'Converts between relative, absolute, and URL portable file names.',
236        argnames is ['Relative', 'Absolute', 'URL'],
237        exceptions is [
238            'None of the arguments is instantiated' - instantiation_error,
239            'Relative is neither a variable nor a relative file name' - type_error(relative_file_name, 'Relative'),
240            'Absolute is neither a variable nor a absolute file name' - type_error(absolute_file_name, 'Absolute'),
241            'URL is neither a variable nor a file name URL' - type_error(url_file_name, 'URL')]]).
242
243    :- public(relative_file_name/1).
244    :- mode(relative_file_name(+atom), zero_or_one).
245    :- info(relative_file_name/1, [
246        comment is 'True when the argument is a valid, relative file name. Argument is expanded to a canonical file name before testing.',
247        argnames is ['File'],
248        exceptions is [
249            'File is not instantiated' - instantiation_error,
250            'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
251
252    :- public(absolute_file_name/1).
253    :- mode(absolute_file_name(+atom), zero_or_one).
254    :- info(absolute_file_name/1, [
255        comment is 'True if the argument is a valid, absolute file name. Argument is expanded to a canonical file name before testing.',
256        argnames is ['File'],
257        exceptions is [
258            'File is not instantiated' - instantiation_error,
259            'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
260
261    :- public(url_file_name/1).
262    :- mode(url_file_name(+atom), zero_or_one).
263    :- info(url_file_name/1, [
264        comment is 'True when the argument is a valid, URL file name. Argument is expanded to a canonical file name before testing.',
265        argnames is ['File'],
266        exceptions is [
267            'File is not instantiated' - instantiation_error,
268            'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
269
270    :- public(absolute_file_name/2).
271    :- mode(absolute_file_name(+atom, ?atom), zero_or_one).
272    :- info(absolute_file_name/2, [
273        comment is 'Expands a file name into a canonical absolute file name.',
274        argnames is ['File', 'Absolute'],
275        exceptions is [
276            'File is not instantiated' - instantiation_error,
277            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
278            'Absolute is neither a variable nor a valid file name' - type_error(file_name, 'Absolute')]]).
279
280    :- public(url_file_name/2).
281    :- mode(url_file_name(+atom, ?atom), zero_or_one).
282    :- info(url_file_name/2, [
283        comment is 'Expands a file name into a canonical URL file name.',
284        argnames is ['File', 'URL'],
285        exceptions is [
286            'File is not instantiated' - instantiation_error,
287            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
288            'URL is neither a variable nor a valid file name URL' - type_error(file_name, 'URL')]]).
289
290    :- public(file_name_part/2).
291    :- mode(file_name_part(+atom, ?compound), zero_or_more).
292    :- info(file_name_part/2, [
293        comment is 'File name parts. The file name is expanded to a canonical file name before decomposing in parts.',
294        argnames is ['File', 'Part'],
295        exceptions is [
296            'File is not instantiated' - instantiation_error,
297            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
298            'File does not exists' - existence_error(file, 'File'),
299            'Part is neither a variable nor a file name part' - type_error(file_name_part, 'Port')]]).
300
301    :- public(file_name_parts/2).
302    :- mode(file_name_parts(+atom, -list(compound)), one).
303    :- mode(file_name_parts(-atom, +list(compound)), zero_or_one).
304    :- info(file_name_parts/2, [
305        comment is 'Converts between a file name and its constituent parts (represented as a list of compound terms). The file name (when instantiated) is expanded to a canonical file name before decomposing in parts.',
306        argnames is ['File', 'Parts'],
307        exceptions is [
308            'None of the arguments are instantiated' - instantiation_error,
309            'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
310            'Parts is neither a variable nor a list' - type_error(list(compound), 'Parts')]]).
311
312:- end_protocol.
Note: See TracBrowser for help on using the browser.