This HTML automatically generated with rman for NEMO
Table of Contents

Name

nemo_file_size, nemo_file_time, nemo_file_lines - get size (in bytes/lines) of a file

Synopsis


int nemo_file_size(name)char *name;int nemo_file_time(name)char *name;
int
nemo_file_lines(name, deflen)char *nameint deflen

Description

nemo_file_size can be used to check for the existence of a file. It returns, as a non-negative number, the file size in bytes. If the file is not found, or an error was detected in the stat(2) call, -1 is returned and errno is set to indicate the error. The file must be a regular file, not part of a pipe stdin/out stream.

nemo_file_time is simular to nemo_file_size., except it returns the age of a file in seconds, since 1970.0 in the usual fashion (see also stat(2) ).

nemo_file_lines counts the number of lines in a text file but counting the number of occurences of a newline. This routine will hence not work correctly on MSDOS. Also, the file must be a proper file, as detected with isatty(3) . A hint, defline can be given, to simplify use in calling programs. A positive number means that both a pipe and file will return this number (and hence possibly not read enough). Zero will force computation of the number of lines by scanning over the file, which can only be done for true files, and is expensive. Pipes will use the MAXLINES (see stdinc.h, normally 10000) macro. For negatives values, pipes will use -deflen, whereas files will do the expensive computation.

Namespace

Earlier versions did not have the name nemo_ prepended, until some library was using the same name as ours....

Bugs

If stropen(3NEMO) is used to open the file, isatty(3) does not properly report the file status anymore.

See Also

stat(2) , isatty(3) , stropen(3NEMO)

Files


~/src/kernel/cores      file_size.c file_size.3

Author

Peter Teuben

Update History


8-feb-90    V1.0 created for SUN’s    PJT
25-nov-90    V1.1 doc written for earlier released file_lines      PJT
7-jun-96    documented outstanding (nov93) argument change in file_lines    pjt
24-oct-97    added file_time()    PJT
21-sep-03    changed meaning of deflen in nemo_file_lines    PJT


Table of Contents