X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fstat.h;fp=source%2Ffs%2Fstat.h;h=55a1fec51b575f50b0208878a4e066a20383c98f;hp=0000000000000000000000000000000000000000;hb=af94bc926e301e9b871dc18662b4fa6e5614fdbf;hpb=fa77438b62207466c48620604c8cc34931080936 diff --git a/source/fs/stat.h b/source/fs/stat.h new file mode 100644 index 0000000..55a1fec --- /dev/null +++ b/source/fs/stat.h @@ -0,0 +1,51 @@ +/* $Id$ + +This file is part of libmspfs +Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#ifndef MSP_FS_STAT_H_ +#define MSP_FS_STAT_H_ + +#include +#include "path.h" + +namespace Msp { +namespace FS { + +/** +Gets information about a file. Returns 0 on success or -1 on error. This +version can be used to check for file existence and get information in one +call. +*/ +int stat(const Path &fn, struct stat &st); + +/** +Returns information about a file. This version throws an exception if an error +occurs. +*/ +struct stat stat(const Path &fn); + +/// Gets information about a file, without following symbolic links +int lstat(const Path &fn, struct stat &st); + +/// Returns information about a file, without following symbolic links +struct stat lstat(const Path &fn); + +/// Tests for existence of a file +bool exists(const Path &path); + +/// Tests whether a path refers to an existing regular file +bool is_reg(const Path &path); + +/// Tests whether a path refers to an existing directory +bool is_dir(const Path &path); + +/// Tests whether a path refers to a symbolic link +bool is_link(const Path &path); + +} // namespace FS +} // namespace Msp + +#endif