[Index for tmp_for_tar/vrml.doc]
[Return to Master Index]
slurp_file
(tmp_for_tar/vrml.doc/slurp_file.m)
Function Synopsis
s = slurp_file (f)
Help text
s = slurp_file (f) - return a whole text file as a string
f : string : filename
s : string : contents of the file
If f is not an absolute filename, and f is not an immediately accessible
file, slurp_file () will look for f in LOADPATH.
Last modified: December 2000
Listing of function file tmp_for_tar/vrml.doc/slurp_file.m
## s = slurp_file (f) - return a whole text file as a string
##
## f : string : filename
## s : string : contents of the file
##
## If f is not an absolute filename, and f is not an immediately accessible
## file, slurp_file () will look for f in LOADPATH.
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: December 2000
function s = slurp_file (f)
if ! isstr (f), error ("slurp_file : f is not a string"); end
if ! length (f), error ("slurp_file : f is empty"); end
s = "";
f0 = f;
[st,err,msg] = stat (f);
if err && f(1) != "/",
f = file_in_path (LOADPATH, f);
# Could not find it anywhere. Open will
# fail.
if strcmp (f, "undefined"),
f = f0;
error ("slurp_file : Can't find '%s' anywhere",f0);
end
end
## I'm too lazy for that
## if fid = open (f,"r")
## I'll even get decent error messages!
s = system (sprintf ("cat %s",f), 1);
Produced by oct2html on Sat Dec 2 19:08:39 2000
Cross-Directory links are: ON