NaviServer - programmable web server

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

# ns_filestat(n) 4.99.8 naviserver "NaviServer Built-in Commands"

## Name

ns_filestat - Returns information about a file

## Table Of Contents

## Synopsis

- ns_filestat FileName ?VarName?

## 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 struc- ture; 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 exisst, 0 if not accesable

## EXAMPLES

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