Vely logo install
examples
documentation

Vely 15.2.0 released on Jan 18, 2023
Articles updated Jan 17, 2023

stat-file


Issues with this documentation page? Report here.

Purpose:


Get information about a file.

Syntax:



stat-file <file> \
    size | type | path | name \
    to [ define ] <variable>


Description:


stat-file gets information about <file>, which is either the full path of a file or directory, or a name relative to the application home directory (see how_vely_works).

Clause "size" will store file's size in bytes to <variable>, or it will be VV_ERR_FAILED (if operation failed, likely because file does not exist or you have no permissions to access it).

Clause "type" will store file's type to number <variable>, and it can be either VV_FILE (if it's a file) or VV_DIR (if it's a directory) or VV_ERR_FAILED (if operation failed, likely because file does not exist or you have no permissions to access it).

Clause "path" gets the fully resolved path of the <file> (including symbolic links), and "name" is the name (a basename, without the path). The results of both "path" and "name" clauses are allocated memory. If path cannot be resolved, then <variable> is an empty string.

Examples:


To get file size in variable "sz", which is created here:

stat-file "/home/user/file" size to define sz

To determine if the object is a file or a directory:

stat-file "/home/user/some_name" type to define what
if (what == VV_FILE) {
   @It's a file!
} else if (what == VV_DIR) {
   @It's a directory!
} else {
   @Doesn't exist!
}

Get the fully resolved path of a file to string variable "fp", which is created here.

stat-file "../file" path to define fp


See also:


Files ( close-file   copy-file   delete-file   file-position   file_storage   file_uploading   lock-file   open-file   read-file   read-line   rename-file   stat-file   temporary_file   uniq-file   unlock-file   write-file  )  SEE ALL (documentation)



Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Vely elephant logo (c) 2022 DaSoftver LLC. This web page is licensed under CC-BY-SA-4.0.