NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_filestat(n) 4.99.30 naviserver "NaviServer Built-in Commands"

Name

ns_filestat - Returns information about a file

Table Of Contents

Synopsis

Description

Invokes the stat kernel call on name, and uses the variable given by varName to hold information returned from the kernel call. VarName is treated as an array variable, and the following elements of that variable are set: atime, ctime, dev, gid, ino, mode, mtime, nlink, size, type, uid. Each element except type is a decimal string with the value of the corresponding field from the stat return structure; see the manual entry for stat for details on the meanings of the values. The type element gives the type of the file in the same form returned by the command file type. This command returns 1 if system call was successful and array varianle is set or 0 in case of any error or file not found.

If Tcl VFS was compiled this command is similar to Tcl file stat command. In case of no Tcl VFS, this command uses direct system call stat and is much faster.

COMMANDS

ns_filestat FileName ?VarName?

If VarName is not specified, then ns_filestat behaves similar to file exists, just returns 1 if file exist, 0 if not accessible

EXAMPLES

 if { [ns_filestat /tmp/info.txt stat] } {
   ns_log notice $stat(size)
 }

Keywords

global built-in