Skip to content

Modern Fs Stat

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Filesystem › Filesystem Library › Stat

Stat

Returns a path's FileInfo, following symbolic links; fails if the path is missing.

Syntax

Stat( p )

Notes

  • FsResultInfo -- FOLLOWS symbolic links

Examples

#import "std/fs"
using fs

dim td as FsResultUStr = CreateTempDir( "fbdoc" )
dim as ustring dir_ = td.Value( )
dim as ustring p = PathJoin( dir_, "f.txt" )
WriteAllText( p, "hello" )

dim r as FsResultInfo = Stat( p )

print r.IsOk( )              '' true
print r.Value( ).Size( )     '' 5
print r.Value( ).IsFile( )   '' true

'' ONE syscall for everything: size, kind, times and attributes come
'' back together, so a loop over a directory does not stat each file
'' repeatedly to ask it three questions.
''
'' FOLLOWS SYMLINKS. LStat is the same call that does not.
dim miss as FsResultInfo = Stat( PathJoin( dir_, "nope" ) )
print miss.IsOk( )                       '' false
print miss.Failure( ).Code( ) = FS_NOT_FOUND     '' -1 (true)

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: Metadata

Clone this wiki locally