fexists added

This commit is contained in:
Dmitry Boulytchev 2021-11-19 01:38:22 +03:00
parent eb098a6fac
commit 9ff649e563
5 changed files with 28 additions and 13 deletions

Binary file not shown.

View file

@ -26,6 +26,7 @@ F,fopen;
F,fclose; F,fclose;
F,fread; F,fread;
F,fwrite; F,fwrite;
F,fexists;
F,failure; F,failure;
F,read; F,read;
F,write; F,write;

View file

@ -1427,6 +1427,18 @@ extern void Lfwrite (char *fname, char *contents) {
failure ("fwrite (\"%s\"): %s\n", fname, strerror (errno)); failure ("fwrite (\"%s\"): %s\n", fname, strerror (errno));
} }
extern void* Lfexists (char *fname) {
FILE *f;
ASSERT_STRING("fexists", fname);
f = fopen (fname, "r");
if (f) return BOX(1);
return BOX(0);
}
extern void* Lfst (void *v) { extern void* Lfst (void *v) {
return Belem (v, BOX(0)); return Belem (v, BOX(0));
} }

View file

@ -87,6 +87,8 @@ is automatically open and closed within the call.}
\descr{\lstinline|fun fwrite (fname, contents)|}{Writes a file. The arguments are file name and the contents to write as strings. The file \descr{\lstinline|fun fwrite (fname, contents)|}{Writes a file. The arguments are file name and the contents to write as strings. The file
is automatically created and closed within the call.} is automatically created and closed within the call.}
\descr{\lstinline|fun fexists (fname)|}{Checks if a file exists. The argument is the file name.}
\descr{\lstinline|fun fprintf (file, fmt, ...)|}{Same as "\lstinline|printf|", but outputs to a given file. The file argument should be that acquired \descr{\lstinline|fun fprintf (file, fmt, ...)|}{Same as "\lstinline|printf|", but outputs to a given file. The file argument should be that acquired
by \lstinline|fopen| function.} by \lstinline|fopen| function.}

View file

@ -1 +1 @@
let version = "Version 1.10, 594fa7bf8, Sat Oct 30 19:24:25 2021 +0300" let version = "Version 1.10, eb098a6fa, Sun Oct 31 15:34:34 2021 +0300"