[mercury-users] io.m, directory listing
Tomas By
tomas at research.nj.nec.com
Thu Oct 7 14:25:37 AEST 1999
Fergus Henderson writes:
> Well, looking at the functionality, io.m has facilities for creating files,
> so it seems to make sense for it to also have facilities for deleting them.
Hmm ok fair enuf. But then why exclude the POSIX stuff in <sys/stat.h>
and <unistd.h>?
(You can find out file size with what's in `io.m' now, by reading the
whole file into memory, so why can't you read the size directly?)
Here's what I have in `dir.m' now. If you (or anyone else) have
suggestions for changes/additions etc, I'd be happy to change things
before I submit it to you.
(What I'd like to do is put it all in `io.m' for the reasons I gave earlier.)
I'll add some time functions as well I think.
I skipped links (I'm using `lstat' to read attributes) and uid/gid
because I wasn't sure how that works under windows. (Plus laziness)
/Tomas
% -----------------------------------------------------------------------------
% directory stuff
:- import_module io, list.
% dir__get_cwd( Path, IO_state, IO_state )
% Returns current dir as absolute filename.
:- pred dir__get_cwd(io__res(string),io__state,io__state).
:- mode dir__get_cwd(out,di,uo) is det.
% dir__chdir( Path, Result, IO_state, IO_state )
% Changes current dir.
:- pred dir__chdir(string,io__res,io__state,io__state).
:- mode dir__chdir(in,out,di,uo) is det.
% dir__mkdir( Path, Result, IO_state, IO_state )
% Creates a directory.
:- pred dir__mkdir(string,io__res,io__state,io__state).
:- mode dir__mkdir(in,out,di,uo) is det.
% dir__rmdir( Path, Result, IO_state, IO_state )
% removes a directory.
:- pred dir__rmdir(string,io__res,io__state,io__state).
:- mode dir__rmdir(in,out,di,uo) is det.
% dir__list( Name, Files, IO_state, IO_state )
% Returns a list of all files in the directory `Name'.
:- pred dir__list(string,io__res(list(string)),io__state,io__state).
:- mode dir__list(in,out,di,uo) is det.
% type tests
:- import_module bool.
% dir__access( Name, IO_state, IO_state )
% Tests if the file `Name' exists.
:- pred dir__access(string,io__res,io__state,io__state).
:- mode dir__access(in,out,di,uo) is det.
:- mode dir__access(in,in,di,uo) is semidet.
% dir__is_regular_file( Name, IO_state, IO_state )
% Tests if the file `Name' is a regular file.
:- pred dir__is_regular_file(string,io__res(bool),io__state,io__state).
:- mode dir__is_regular_file(in,out,di,uo) is det.
% dir__is_directory( Name, IO_state, IO_state )
% Tests if the file `Name' is a directory.
:- pred dir__is_directory(string,io__res(bool),io__state,io__state).
:- mode dir__is_directory(in,out,di,uo) is det.
% file size
:- interface.
% dir__get_size( Name, Result, IO_state, IO_state )
% Returns size in bytes.
:- pred dir__get_size(string,io__res(int),io__state,io__state).
:- mode dir__get_size(in,out,di,uo) is det.
% dir__get_blocks( Name, Result, IO_state, IO_state )
% Returns number of (512-byte) blocks.
:- pred dir__get_blocks(string,io__res(int),io__state,io__state).
:- mode dir__get_blocks(in,out,di,uo) is det.
% dir__get_optimal_blocksize( Name, Result, IO_state, IO_state )
% Returns size in bytes.
:- pred dir__get_optimal_blocksize(string,io__res(int),io__state,io__state).
:- mode dir__get_optimal_blocksize(in,out,di,uo) is det.
% Absolute path.
% dir__absolute_path( Path, Result, IO__state, IO__state )
% Converts `Path' to absolute (starting with `/' and no `..').
:- pred dir__absolute_path(string,io__res(string),io__state,io__state).
:- mode dir__absolute_path(in,out,di,uo) is det.
% -----------------------------------------------------------------------------
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list