The Meta-Environment API

io-utils.tb

Go to the documentation of this file.
00001 #ifndef __IO_UTILS__
00002 #define __IO_UTILS__
00003 
00004 #include <in-output.idef>
00005 
00006 process RemoveFile(Path: str) is
00007 let
00008   Summary: summary
00009 in
00010   snd-msg(io-remove-file(Path))
00011   .
00012   (
00013     rec-msg(io-file-removed(Path))
00014   +
00015     rec-msg(io-file-not-removed(Path, Summary?))
00016     . DisplaySummary(Summary)
00017   )
00018 endlet
00019 
00020 process ReadFile(Path: str, Contents: str?) is
00021 let
00022   Summary: summary
00023 in
00024   snd-msg(io-read-file(Path))
00025   .
00026   (
00027     rec-msg(io-file-contents(Contents?))
00028   +
00029     rec-msg(io-error-reading(Summary?))
00030     . Contents := ""
00031   )
00032 endlet
00033 
00034 process BuildPath(Directory: str, Filename: str, Extension: str, Path: str?) is
00035   snd-msg(io-get-filename(Directory, Filename, Extension))
00036   . rec-msg(io-filename(Path?))
00037 
00038 process ReplaceExtension(SrcPath: str, NewExtension: str, DstPath: str?) is
00039 let
00040   Directory: str,
00041   OldExtension: str,
00042   Filename: str
00043 in
00044   SplitFilename(SrcPath, Filename?, Directory?, OldExtension?)
00045   . BuildPath(Directory, Filename, NewExtension, DstPath?)
00046 endlet
00047 
00048 process DealWithMultipleOccurrences(Chosen: str, Name: str, Extension: str,
00049                                     Peers: list) is
00050 let
00051   Directories: list,
00052   Directory: str,
00053   FileName: str,
00054   PeerName: str
00055 in
00056   Directories := Peers
00057   .
00058   if not-equal(Directories, []) then
00059     Directory := first(Directories)
00060     . Directories := next(Directories)
00061     . BuildPath(Directory, Name, Extension, FileName?)
00062     . BuildPath(Chosen, Name, Extension, PeerName?)
00063     . snd-msg(io-compare-files(PeerName, FileName))
00064     .
00065     (
00066       rec-msg(io-files-equal)
00067     +
00068       rec-msg(io-files-differ)
00069       . snd-note(ui-status(messagef("Multiple occurrences of %s. Continuing with %s",
00070                                     [Name, PeerName])))
00071     )
00072   fi
00073   *
00074   if equal(Directories, []) then
00075     tau
00076   fi
00077 endlet
00078 
00079 process SplitFilename(Path : str, 
00080                       FileName : str?,
00081               Directory : str?, 
00082               Extension : str?) is
00083   snd-msg(io-get-path-filename(Path))
00084   . rec-msg(io-filename(Path, FileName?))
00085   . snd-msg(io-get-path-directory(Path))
00086   . rec-msg(io-directory(Path, Directory?))
00087   . snd-msg(io-get-path-extension(Path))
00088   . rec-msg(io-extension(Path, Extension?))
00089 
00090 process UnPackTree(Tree : term, UnpackedTree : term?) is
00091   snd-msg(io-unpack-term(Tree))
00092   . rec-msg(io-term(UnpackedTree?))
00093 
00094 process PackTree(Tree : term, PackedTree : term?) is
00095   snd-msg(io-pack-term(Tree))
00096   . rec-msg(io-term(PackedTree?))
00097 #endif

Generated on Fri Sep 12 13:08:53 2008 for meta by  doxygen 1.4.6