library(file_systems)
This module provides operations on files and directories, such as renaming, deleting, opening, checking permissions, accessing members of.
The following principles have been observed:
absolute_file_name/3
.
library(directory)
raise an error exception. Any time that a predicate
fails quietly, it should mean “this question is meaningful, but the
answer is no”.
The “property” routines use the same simplistic access control
model as that used by the absolute_file_name/3
access/1
-option. See mpg-ref-absolute_file_name, for details.
Exported predicates:
rename_file(
+OldName,
+NewName)
rename_directory(
+OldName,
+NewName)
delete_file(
+OldName)
delete_directory(
+Directory)
delete_directory(
+Directory,
+Options)
if_nonempty(
Value)
ignore
fail
error
delete
directory_exists(
+Directory)
directory_exists(
+Directory,
+Mode)
exist
.
This is more or less equivalent to
absolute_file_name(
File, _, [file_type(directory), access([exist|
Mode]), file_errors(fail)])
.
make_directory(
+Directory)
absolute_file_name/3
,
and the resulting directory is created.
file_exists(
+File)
file_exists(
+File,
+Mode)
exist
.
This is more or less equivalent to
absolute_file_name(
File, _, [access([exist|
Mode]), file_errors(fail)])
.
file_must_exist(
+File)
file_must_exist(
+File,
+Mode)
file_exists(
File[,
Mode])
except that if the file is not
accessible it reports an error.
This is more or less equivalent to
absolute_file_name(
File, _, [access([exist|
Mode]), file_errors(error)])
.
directory_must_exist(
+File)
directory_must_exist(
+File,
+Mode)
file_must_exists(
File[,
Mode])
, but for directories.
This is more or less equivalent to
absolute_file_name(
File, _, [file_type(directory), access([exists|
Mode]), file_errors(error)])
.
close_all_streams
abort/0
. Note that current_stream/3
does not notice the standard
streams.
directory_member_of_directory(
?BaseName,
?FullName)
This uses absolute_file_name/3
with the glob/1
option.
directory_member_of_directory(
+Directory,
?BaseName,
?FullName)
This uses absolute_file_name/3
with the glob/1
option.
directory_member_of_directory(
+Directory,
+Pattern,
?BaseName,
?FullName)
This uses absolute_file_name/3
with a glob(
Pattern)
option.
directory_members_of_directory(
-Set)
This uses absolute_file_name/3
with the glob/1
option.
directory_members_of_directory(
+Directory,
-Set)
This uses absolute_file_name/3
with the glob/1
option.
directory_members_of_directory(
+Directory,
+Pattern,
-Set)
This uses absolute_file_name/3
with a glob(
Pattern)
option.
file_member_of_directory(
?BaseName,
?FullName)
This uses absolute_file_name/3
with the glob/1
option.
file_member_of_directory(
+Directory,
?BaseName,
?FullName)
This uses absolute_file_name/3
with the glob/1
option.
file_member_of_directory(
+Directory,
+Pattern,
?BaseName,
?FullName)
This uses absolute_file_name/3
with a glob(
Pattern)
option.
file_members_of_directory(
-Set)
This uses absolute_file_name/3
with the glob/1
option.
file_members_of_directory(
+Directory,
-Set)
This uses absolute_file_name/3
with the glob/1
option.
file_members_of_directory(
+Directory,
+Pattern,
-Set)
This uses absolute_file_name/3
with a glob(
Pattern)
option.
directory_property(
+Directory,
?Property)
directory_property(., searchable).
The current set of file and directory properties include:
readable
writable
executable
searchable
create_timestamp
modify_timestamp
access_timestamp
The timestamp is what should be used when comparing information
between files since it is independent of locale issues like time zone and daylight
savings time etc.
create_localtime
modify_localtime
access_localtime
..._timestamp
values passed
through system:datime/2
, i.e. expressed as local time and
split up in the components year, month, day, hour, minute, seconds.
set_user_id
set_group_id
save_text
who_can_read
who_can_write
who_can_execute
who_can_search
[user,group,other]
for the
process classes that can, respectively, read, write, execute (only for
files) or search (only for directories.
owner_user_id
owner_group_id
owner_user_name
owner_group_group
'
DOMAIN\
NAME'
will be used.
If for some reason the name cannot be found it will fall back to using
the same value as owner_user_id
and owner_group_id
.
Other properties may be added in the future. You can backtrack through
the available properties by calling file_property/3
or
directory_property/3
with an uninstantiated Property
argument.
directory_property(
+Directory,
?Property,
?Value)
directory_property/2
, above, for a list of properties.
file_property(
+File,
?Property)
file_property(., readable).
See directory_property/2
, above, for a list of properties.
file_property(
+File,
?Property,
?Value)
directory_property/2
, above, for a list of properties.
current_directory(
-Directory)
current_directory(
-Directory,
+NewDirectory)