2005-04-23 00:57:45 +01:00
2001-06-06 20:40:57 +01:00
:- protocol(systemp).
:- info([
2004-08-02 17:08:31 +01:00
version is 1.9,
2004-07-09 00:48:59 +01:00
author is 'Portable Operating-System Interface (POSI) initiative',
2004-08-02 17:08:31 +01:00
date is 2004/7/27,
2004-07-09 00:48:59 +01:00
comment is 'Portable operating system access protocol.']).
2001-06-06 20:40:57 +01:00
:- public(make_directory/1).
2004-07-09 00:48:59 +01:00
:- mode(make_directory(+atom), one).
2001-06-06 20:40:57 +01:00
:- info(make_directory/1, [
2004-06-06 23:46:45 +01:00
comment is 'Makes a new directory.',
argnames is ['Directory'],
exceptions is [
2004-07-09 00:48:59 +01:00
'Directory is not instantiated' - instantiation_error,
2004-06-06 23:46:45 +01:00
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
2004-07-25 19:47:43 +01:00
'No permission for making a new directory' - permission_error(write, 'Directory')]]).
2001-06-06 20:40:57 +01:00
:- public(delete_directory/1).
2004-07-09 00:48:59 +01:00
:- mode(delete_directory(+atom), one).
2001-06-06 20:40:57 +01:00
:- info(delete_directory/1, [
2004-07-25 19:47:43 +01:00
comment is 'Deletes a directory (and all of its contents).',
2004-06-06 23:46:45 +01:00
argnames is ['Directory'],
exceptions is [
2004-07-09 00:48:59 +01:00
'Directory is not instantiated' - instantiation_error,
2004-06-06 23:46:45 +01:00
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
2004-07-09 00:48:59 +01:00
'No permission for deleting the directory' - permission_error(write, 'Directory'),
'Directory does not exists' - existence_error(directory, 'Directory')]]).
2001-06-06 20:40:57 +01:00
:- public(change_directory/1).
2004-07-09 00:48:59 +01:00
:- mode(change_directory(+atom), one).
2001-06-06 20:40:57 +01:00
:- info(change_directory/1, [
2004-06-06 23:46:45 +01:00
comment is 'Changes current working directory.',
argnames is ['Directory'],
exceptions is [
2004-07-09 00:48:59 +01:00
'Directory is not instantiated' - instantiation_error,
2004-06-06 23:46:45 +01:00
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
2004-07-09 00:48:59 +01:00
'No permission for accessing the directory' - permission_error(read, 'Directory'),
'Directory does not exists' - existence_error(directory, 'Directory')]]).
2001-06-06 20:40:57 +01:00
:- public(working_directory/1).
2004-11-29 20:36:31 +00:00
:- mode(working_directory(?atom), zero_or_one).
2001-06-06 20:40:57 +01:00
:- info(working_directory/1, [
2004-07-25 19:47:43 +01:00
comment is 'Current working directory (as an absolute file name).',
2004-06-06 23:46:45 +01:00
argnames is ['Directory'],
exceptions is [
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]).
:- public(directory_exists/1).
:- mode(directory_exists(+atom), zero_or_one).
:- info(directory_exists/1, [
2004-07-25 19:47:43 +01:00
comment is 'True if the specified directory exists (irrespective of directory permissions).',
2004-06-06 23:46:45 +01:00
argnames is ['Directory'],
exceptions is [
2004-07-09 00:48:59 +01:00
'Directory is not instantiated' - instantiation_error,
2004-07-25 19:47:43 +01:00
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]).
2001-06-06 20:40:57 +01:00
:- public(directory_files/2).
2004-07-09 00:48:59 +01:00
:- mode(directory_files(+atom, -list), one).
2001-06-06 20:40:57 +01:00
:- info(directory_files/2, [
2004-07-25 19:47:43 +01:00
comment is 'List of all directory files (returns an empty list if the directory is empty).',
2004-06-06 23:46:45 +01:00
argnames is ['Directory', 'Files'],
exceptions is [
'Directory is not instantiated' - instantiation_error,
'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'),
2004-07-09 00:48:59 +01:00
'No read permission for the directory' - permission_error(read, 'Directory'),
'Directory does not exists' - existence_error(directory, 'Directory')]]).
2002-05-28 12:29:37 +01:00
2001-06-06 20:40:57 +01:00
:- public(delete_file/1).
2004-07-09 00:48:59 +01:00
:- mode(delete_file(+atom), one).
2001-06-06 20:40:57 +01:00
:- info(delete_file/1, [
comment is 'Deletes a file.',
2004-06-06 23:46:45 +01:00
argnames is ['File'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
2004-07-09 00:48:59 +01:00
'File does not exists' - existence_error(file, 'File'),
'No write permission to the file' - permission_error(write, 'File')]]).
2001-06-06 20:40:57 +01:00
2002-05-28 12:29:37 +01:00
:- public(rename_file/2).
:- mode(rename_file(+atom, +atom), zero_or_one).
:- info(rename_file/2, [
2004-07-25 19:47:43 +01:00
comment is 'Renames a file (or a directory).',
2004-06-06 23:46:45 +01:00
argnames is ['Old', 'New'],
exceptions is [
'Old is not instantiated' - instantiation_error,
'New is not instantiated' - instantiation_error,
'Old is neither a variable nor a valid file name' - type_error(file_name, 'Old'),
'New is neither a variable nor a valid file name' - type_error(file_name, 'New'),
2004-07-09 00:48:59 +01:00
'File Old does not exists' - existence_error(file, 'Old'),
'No write permission to the file' - permission_error(write, 'Old')]]).
2004-06-06 23:46:45 +01:00
:- public(copy_file/2).
2004-07-09 00:48:59 +01:00
:- mode(copy_file(+atom, +atom), one).
2004-06-06 23:46:45 +01:00
:- info(copy_file/2, [
comment is 'Makes a copy of a file.',
argnames is ['Original', 'Copy'],
exceptions is [
'Original is not instantiated' - instantiation_error,
'Copy is not instantiated' - instantiation_error,
'Original is neither a variable nor a valid file name' - type_error(file_name, 'Original'),
'Copy is neither a variable nor a valid file name' - type_error(file_name, 'Copy'),
2004-07-09 00:48:59 +01:00
'File Original does not exists' - existence_error(file, 'Original'),
'No read permission to the original file' - permission_error(read, 'Original'),
'No write permission to the file copy' - permission_error(write, 'Copy')]]).
2004-06-06 23:46:45 +01:00
2004-07-25 19:47:43 +01:00
:- public(make_symlink/2).
:- mode(make_symlink(+atom, +atom), one).
:- info(make_symlink/2, [
comment is 'Makes a symbolic link.',
2004-07-09 00:48:59 +01:00
argnames is ['Symlink', 'Target'],
exceptions is [
'Symlink is not instantiated' - instantiation_error,
2004-07-25 19:47:43 +01:00
'Target is not instantiated' - instantiation_error,
2004-07-09 00:48:59 +01:00
'Symlink is neither a variable nor a valid file name' - type_error(file_name, 'Symlink'),
2004-07-25 19:47:43 +01:00
'Target is neither a variable nor a valid file name' - type_error(file_name, 'Target'),
'No permission for creating the symbolic link' - permission_error(write, 'Symlink')]]).
:- public(file_exists/1).
:- mode(file_exists(+atom), zero_or_one).
:- info(file_exists/1, [
comment is 'True if the specified file exists (irrespective of type and file permissions).',
argnames is ['File'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
2004-07-09 00:48:59 +01:00
:- public(file_property/2).
2004-07-25 19:47:43 +01:00
:- mode(file_property(+atom, +compound), zero_or_one).
:- mode(file_property(+atom, -compound), one_or_more).
2004-07-09 00:48:59 +01:00
:- info(file_property/2, [
comment is 'File properties.',
argnames is ['File', 'Property'],
2004-06-06 23:46:45 +01:00
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
2004-07-09 00:48:59 +01:00
'File does not exists' - existence_error(file, 'File'),
2004-07-25 19:47:43 +01:00
'No read permission to the file' - permission_error(read, 'File'),
'Property is neither a variable nor a file property' - type_error(file_property, 'Property')]]).
2004-07-09 00:48:59 +01:00
:- public(current_environment_variable/1).
:- mode(current_environment_variable(?atom), zero_or_more).
:- info(current_environment_variable/1, [
2004-07-25 19:47:43 +01:00
comment is 'Argument is a currently defined environment variable . Fails if the variable does not exists.',
2004-07-09 00:48:59 +01:00
argnames is ['Variable'],
exceptions is [
'Variable is neither a variable nor an atom' - type_error(atom, 'Variable')]]).
2004-06-06 23:46:45 +01:00
2004-07-09 00:48:59 +01:00
:- public(delete_environment_variable/1).
:- mode(delete_environment_variable(+atom), one).
:- info(delete_environment_variable/1, [
comment is 'Deletes an environment variable.',
argnames is ['Variable'],
exceptions is [
'Variable is not instantiated' - instantiation_error,
'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
'Variable is not a currenttly defined environment variable' - existence_error(environment_variable, 'Variable')]]).
:- public(get_environment_variable/2).
:- mode(get_environment_variable(+atom, ?atom), zero_or_one).
:- info(get_environment_variable/2, [
2004-06-06 23:46:45 +01:00
comment is 'Gets environment variable value.',
argnames is ['Variable', 'Value'],
exceptions is [
'Variable is not instantiated' - instantiation_error,
'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
2004-07-09 00:48:59 +01:00
'Value is neither a variable nor an atom' - type_error(atom, 'Value'),
'Variable is not a currenttly defined environment variable' - existence_error(environment_variable, 'Variable')]]).
2004-06-06 23:46:45 +01:00
:- public(set_environment_variable/2).
2004-07-09 00:48:59 +01:00
:- mode(set_environment_variable(+atom, +atom), one).
2004-06-06 23:46:45 +01:00
:- info(set_environment_variable/2, [
comment is 'Sets environment variable value.',
argnames is ['Variable', 'Value'],
exceptions is [
'Variable is not instantiated' - instantiation_error,
'Value is not instantiated' - instantiation_error,
'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'),
'Value is neither a variable nor an atom' - type_error(atom, 'Value')]]).
:- public(time_stamp/1).
:- mode(time_stamp(-number), one).
:- info(time_stamp/1, [
2004-07-25 19:47:43 +01:00
comment is 'Returns a system-dependent time stamp (which can be used for sorting).',
2004-06-06 23:46:45 +01:00
argnames is ['Time']]).
2004-07-09 00:48:59 +01:00
:- public(local_time/1).
:- mode(local_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
:- info(local_time/1, [
comment is 'Local time (respecting time zone and daylight savings settings).',
2004-12-25 03:06:18 +00:00
argnames is ['time(Year, Month, Day, Hours, Mins, Secs, Microsecs)']]).
2004-07-09 00:48:59 +01:00
:- public(utc_time/1).
:- mode(utc_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
:- info(utc_time/1, [
2004-07-25 19:47:43 +01:00
comment is 'Universal Coordinated Time (UTC).',
2004-12-25 03:06:18 +00:00
argnames is ['time(Year, Month, Day, Hours, Mins, Secs, Microsecs)']]).
2004-07-09 00:48:59 +01:00
:- public(convert_time/2).
:- mode(convert_time(+number, ?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one).
2004-07-25 19:47:43 +01:00
:- mode(convert_time(?number, +time(+integer, +integer, +integer, +integer, +integer, +integer, +integer)), zero_or_one).
2004-07-09 00:48:59 +01:00
:- info(convert_time/2, [
2004-07-25 19:47:43 +01:00
comment is 'Converts between system-dependent time stamps and calendar local date and time.',
2004-12-25 03:06:18 +00:00
argnames is ['Time', 'time(Year, Month, Day, Hours, Mins, Secs, Microsecs)'],
2004-06-06 23:46:45 +01:00
exceptions is [
2004-07-25 19:47:43 +01:00
'Neither argument is instantiated' - instantiation_error,
'Time stamp is neither a variable nor a valid time stamp' - type_error(time_stamp, 'Time'),
'Time structure is neither a variable nor a valid time structure' - type_error(time_structure, 'time(Year, Month, Day, Hours, Mins, Secs, Microsecs)')]]).
2004-06-06 23:46:45 +01:00
:- public(cpu_time/1).
2004-07-09 00:48:59 +01:00
:- mode(cpu_time(-number), one).
2004-06-06 23:46:45 +01:00
:- info(cpu_time/1, [
comment is 'System cpu time in seconds.',
argnames is ['Time']]).
:- public(host_name/1).
:- mode(host_name(-atom), one).
:- info(host_name/1, [
2004-07-09 00:48:59 +01:00
comment is 'Host name (default is localhost).',
2004-06-06 23:46:45 +01:00
argnames is ['Name']]).
2004-08-02 17:08:31 +01:00
:- public(portable_os_file_name/2).
:- mode(portable_os_file_name(+atom, -atom), one).
:- mode(portable_os_file_name(-atom, +atom), one).
:- info(portable_os_file_name/2, [
comment is 'Converts between portable and operating-system dependent file names.',
2004-06-06 23:46:45 +01:00
argnames is ['Canonical', 'OS']]).
2004-08-02 17:08:31 +01:00
:- public(portable_file_name/3).
:- mode(portable_file_name(+atom, -atom, -atom), one).
:- mode(portable_file_name(-atom, +atom, -atom), one).
:- mode(portable_file_name(-atom, -atom, +atom), one).
:- info(portable_file_name/3, [
comment is 'Converts between relative, absolute, and URL portable file names.',
2004-07-09 00:48:59 +01:00
argnames is ['Relative', 'Absolute', 'URL'],
2004-06-06 23:46:45 +01:00
exceptions is [
'None of the arguments is instantiated' - instantiation_error,
2004-07-25 19:47:43 +01:00
'Relative is neither a variable nor a relative file name' - type_error(relative_file_name, 'Relative'),
'Absolute is neither a variable nor a absolute file name' - type_error(absolute_file_name, 'Absolute'),
2004-07-09 00:48:59 +01:00
'URL is neither a variable nor a file name URL' - type_error(url_file_name, 'URL')]]).
2004-06-06 23:46:45 +01:00
:- public(relative_file_name/1).
:- mode(relative_file_name(+atom), zero_or_one).
:- info(relative_file_name/1, [
2004-08-02 17:08:31 +01:00
comment is 'True when the argument is a valid, relative file name. Argument is expanded to a canonical file name before testing.',
2004-06-06 23:46:45 +01:00
argnames is ['File'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
:- public(absolute_file_name/1).
:- mode(absolute_file_name(+atom), zero_or_one).
:- info(absolute_file_name/1, [
2004-08-02 17:08:31 +01:00
comment is 'True if the argument is a valid, absolute file name. Argument is expanded to a canonical file name before testing.',
2004-06-06 23:46:45 +01:00
argnames is ['File'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
2004-07-09 00:48:59 +01:00
:- public(url_file_name/1).
:- mode(url_file_name(+atom), zero_or_one).
:- info(url_file_name/1, [
2004-08-02 17:08:31 +01:00
comment is 'True when the argument is a valid, URL file name. Argument is expanded to a canonical file name before testing.',
2004-06-06 23:46:45 +01:00
argnames is ['File'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]).
:- public(absolute_file_name/2).
:- mode(absolute_file_name(+atom, ?atom), zero_or_one).
:- info(absolute_file_name/2, [
2004-08-02 17:08:31 +01:00
comment is 'Expands a file name into a canonical absolute file name.',
2004-06-06 23:46:45 +01:00
argnames is ['File', 'Absolute'],
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
'Absolute is neither a variable nor a valid file name' - type_error(file_name, 'Absolute')]]).
2004-07-09 00:48:59 +01:00
:- public(url_file_name/2).
:- mode(url_file_name(+atom, ?atom), zero_or_one).
:- info(url_file_name/2, [
2004-08-02 17:08:31 +01:00
comment is 'Expands a file name into a canonical URL file name.',
2004-07-09 00:48:59 +01:00
argnames is ['File', 'URL'],
2004-06-06 23:46:45 +01:00
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
2004-07-09 00:48:59 +01:00
'URL is neither a variable nor a valid file name URL' - type_error(file_name, 'URL')]]).
2004-06-06 23:46:45 +01:00
2004-07-09 00:48:59 +01:00
:- public(file_name_part/2).
2004-07-25 19:47:43 +01:00
:- mode(file_name_part(+atom, ?compound), zero_or_more).
2004-07-09 00:48:59 +01:00
:- info(file_name_part/2, [
2004-08-02 17:08:31 +01:00
comment is 'File name parts. The file name is expanded to a canonical file name before decomposing in parts.',
2004-07-09 00:48:59 +01:00
argnames is ['File', 'Part'],
2004-06-06 23:46:45 +01:00
exceptions is [
'File is not instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
2004-07-09 00:48:59 +01:00
'File does not exists' - existence_error(file, 'File'),
'Part is neither a variable nor a file name part' - type_error(file_name_part, 'Port')]]).
2004-06-06 23:46:45 +01:00
:- public(file_name_parts/2).
2004-07-25 19:47:43 +01:00
:- mode(file_name_parts(+atom, -list(compound)), one).
:- mode(file_name_parts(-atom, +list(compound)), zero_or_one).
2004-06-06 23:46:45 +01:00
:- info(file_name_parts/2, [
2004-08-02 17:08:31 +01:00
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.',
2004-06-06 23:46:45 +01:00
argnames is ['File', 'Parts'],
exceptions is [
'None of the arguments are instantiated' - instantiation_error,
'File is neither a variable nor a valid file name' - type_error(file_name, 'File'),
2004-07-25 19:47:43 +01:00
'Parts is neither a variable nor a list' - type_error(list(compound), 'Parts')]]).
2002-08-26 17:45:50 +01:00
2001-06-06 20:40:57 +01:00
:- end_protocol.