FB...tat(3bobcat)
π FB...tat(3bobcat) π
okay bestie, so this is the tea on FBB::Stat β it's all about Characteristics of object in the filesystem, and it lives in the (3bobcat) manual section. grab a snack, this one's a whole saga (part 1 of 2, so don't go anywhere) π
β¨ NAME β¨
FBB::Stat β Determines File Characteristics π
πΈ SYNOPSIS πΈ
#include <bobcat/stat>
Linking option: -lbobcat
that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
so Stat is basically a glow-up wrapper around the stat(2) and lstat(2) system functions. like, it wraps them, but it also serves β¨looksβ¨ β specifically, it gives you straight-up ways to test for the object characteristics those two functions hand you.
here's the important part tho, no cap: to find out whether an object even got constructed properly, use the Stat bool conversion operator. if that operator comes back false, then do not touch any other member except error. none. nada. put it down. π
π NAMESPACE π
FBB
every single constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. periodt.
π INHERITS FROM π
-
(nothing. it inherits from nothing. it's self-made, main character energy fr fr β¨)
π ENUMERATIONS π
π Stat::Combine
this enum defines the following values:
ALLβ require all of the specifiedModeorSpecialModevalues to match;ANYβ require any match of the specifiedModeorSpecialModevalues (one single match suffices, we're not picky π )
π Stat::Mode
this enum defines the following values:
URβ the owner of the object has read permissionsUWβ the owner of the object has write permissionsUXβ the owner of the object has execute permissionsGRβ the group to which the object belongs has read permissionsGWβ the group to which the object belongs has write permissionsGXβ the group to which the object belongs has execute permissionsORβ others have read permissionsOWβ others have write permissionsOXβ others have execute permissionsREADβ equal toUR | GR | ORWRITEβ equal toUW | GW | OWEXECβ equal toUX | GX | OXRWXβ all of the above. every single one. the full set π«Ά
π Stat::SpecialMode
this enum defines the following values:
SUIDβ set UID bit is upSGIDβ set GID bit is upSBβ sticky bit is up
π Stat::Type
this enumeration β which is identical to the glob(3bobcat) Type enumeration, cute little sibling situation β defines the following values:
BLOCK_DEVICE(0060000) β the object is a block device;CHARACTER_DEVICE(0020000) β the object is a character device;DIRECTORY(0040000) β the object is a directory;FIFO(0010000) β the object is a named pipe (a queue);REGULAR_FILE(0100000) β the object is a regular file;SOCKET(0140000) β the object is a socket;SYMBOLIC_LINK(0120000) β the object is a symbolic link;ANYβ any of the above types. basically "surprise me" π
π Stat::Lstat
this enumeration has exactly one value: LStat.
you can pass it to constructors and to some members when you want the Stat object to distinguish regular files from symbolic links β which it does by calling lstat(2) β instead of just treating symbolic links as regular files (which is the stat(2) behaviour).
so here's the rule, bestie:
- constructors and members that define
Stat::Lstatparameters calllstat(2), which means they distinguish symbolic links from regular files; - constructors and members that do not define
Stat::Lstatparameters usestat(2).
also important: the return values of the members statStruct and type and typeStr (see below) only distinguish symbolic links from regular files when the Stat::LStat argument has been used. iykyk π₯
and lastly: the constructors and member functions listed below for which [Stat::Lstat,] is specified as first parameter may optionally specify the Stat::LStat argument.
π§ CONSTRUCTORS π§
Stat()β the default constructor, creating an emptyStatobject. it's mainly used as a default object when you're defining, like,vectorsofStatobjects. since it doesn't refer to an existing file system entry, itsoperator boolreturnsfalse. (it's the empty husk era π)Stat([Stat::Lstat,] std::string const &fname)β initializes aStatwith a given object name.Stat([Stat::Lstat,] std::string const &fname, std::string const &searchPath)β initializes aStatwith a given object name, where the object gets searched in thesearchPathdirectories, which is a colon-separated string of directory names. the filenames are constructed by appendingfnameto each of the elements ofsearchPathuntil an existing object is found β and that object is the one that gets used. oh and iffnameis an absolute path,searchPathis ignored entirely. π«
Copy and move constructors (and assignment operators) are available. slay, very movable, very copyable π
π OVERLOADED OPERATORS π
operator bool() constβ this operator returnstrueif theStatobject holds information about an existing object. otherwisefalseis returned. and whenfalsecomes back, other members should not be used β with the exceptions of the assignment operators, theerrormember, and thesetmembers.
β οΈ real talk bestie: afalsehere means don't touch anything else. the only things you're allowed to go near are the assignment operators,error, and thesetmembers. everything else is off-limits fr fr.
π MEMBER FUNCTIONS π
okay so bestie, this is the whole entire buffet π every single one of these lives on your Stat object and honestly, you're gonna want them all. no skips, no shortcuts, we're going through the whole list together π
bool access(FBB::User const &user, size_t spec, bool useEffective = true) constβ gives youtrueif user has the perms you asked for in spec (only the definedModebits get interpreted, the rest are just vibing in the background). here's the tea: if you specify a combo of read, write and/or execute perms, then at least one read perm, one write perm and one execute perm all have to be granted, otherwise it hands you backfalse. like,access(user, UW | UR | GR)means the user must have write perms, but either the user or the user's group has to have read perms. and if you ask for multiple read, multiple write or multiple execute perms (thinkUR | GR), then it returnstrueif at least one of the requested read, write or execute perms is granted for user. lowkey iconic β¨size_t blockSize() constβ the blocksize for filesystem I/O, akast_blksizeπsize_t device() constβ the device id, akast_devπ¦size_t deviceType() constβ the device type number, but only if the object's type isDEVICE(it'sst_rdev, bestie, just so you know) πsize_t error() constβ the error number tied to an error, only relevant in those sad moments whereoperator bool()returnsfalse. a return value of0meansno errorsπ if you want a verbal transcription of the returned error numbers, that's what theerrnodescrmanipulator is for (cf.manipulators(3bobcat))bool isType(Stat::Type probe)βtrueif the object has the type you probed for, otherwise you getfalseback πsize_t inode() constβ the inode number,st_inoβsize_t gid() constβ the group ID of the object's owner,st_gidπFBB::DateTime lastAccess() constβ anFBB::DateTimeobject holding info about the object's time of last access (st_atime) β and yes, it's in UTC πΈFBB::DateTime lastChange() constβ anFBB::DateTimeobject holding info about the object's time of last status change (st_ctime), also UTC π¦FBB::DateTime lastModification() constβ anFBB::DateTimeobject holding info about the object's last modification time (st_mtime), UTC again, consistent queen πsize_t mode() constβ the object's raw, uninterpreted mode, i.e.st_mode & RWX. heads up, this value is usually displayed (and processed most easily) as an octal value πbool mode(size_t mode, Combine combine = ALL)βtrueif the object has the mode you indicated. multiple modes are allowed and you can smash them together with the logical bitor operator. by default, if you specify multiple modes, the resulting pattern has to exactly represent the object's mode for this to returntrue. there's an optionalANYargument you can pass if you'd rather it returntruewhenever at least one of your specified modes matches the object's actual mode. and if your specified mode contains anything other than the definedModeorSpecialModevalues, anExceptiongets thrown πstd::string modeStr() constβ the standard string representation of the object's mode (likerw-r--r--, cute). special modes (suid, etc.) show up assinstead ofxwhen the object is user and/or group executable, and asSif the object has the special mode bit(s) set but isn't executable. for theotherexecutable mode flag,tis used (thestickybit π), andTif the object isn'totherexecutable πstd::string const &name() constβ the object's name, exactly as you gave it in the constructor or in theset()member function πsize_t nBlocks() constβ the object's number of allocated blocks,st_blocksβ¨size_t nLinks() constβ the object's number of hard links,st_nlinkπ₯std::string path() constβ the object's full pathname. and if the full pathname couldn't be figured out, you get an empty string back, sorry bestie πbool set([Stat::Lstat,] std::string const &name)β redefines theStatobject so it represents the info about the object name you handed it π«Άbool set([Stat::Lstat,] std::string const &name, std::string const &pathlist)β same deal, redefines theStatobject to represent the info about the indicated object name, but now the object gets searched for inside the pathlist directories β which is a colon-separated string of directory names. the object names get constructed by appendingfnameto each of the elements ofsearchPathuntil an existing object turns up, and then that object is the one that gets used. tiny caveat: iffnameis an absolute path,searchPathis ignored, periodt πoff_t size() constβ the object's size in number of bytes,st_sizeπbool specialMode(size_t special, Combine combine = ALL)βtrueif the object has the special modes you indicated. multiple special modes allowed, bitor them together. by default, if you specify multiple modes, the resulting pattern must exactly represent the object's mode for this to returntrue. optionalANYargument if you want it to returntruewhen at least one specified mode matches the object's actual mode. the non-special modes are just ignored here, but anExceptiongets thrown if special contains any values other than those defined by theSpecialModeenum β οΈStat::stat const &statStruct() constβ a reference to the object's stat struct πStat::Type type() constβ theStat::Typevalue of the object π¦std::string typeStr() constβ a textual representation of the object's type, exactly as returned by theStat::type()member function β¨size_t uid() constβ the user ID of the object's owner,st_uidπ
πΈ EXAMPLE πΈ
bestie this is the whole vibe in one file, go off:
#include <iostream>
#include <string>
#include <bobcat/datetime>
#include <bobcat/stat>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
if (argc == 1)
{
cout << "Usage: driver [-l] object [colon-separated searchpath]\n";
return 1;
}
bool lstat = "-l"s == argv[1];
if (lstat)
{
++argv;
--argc;
}
Stat st;
if (argc == 2)
{
if (lstat)
st.set(Stat::LStat, argv[1]);
else
st.set(argv[1]);
}
else if (argc == 3)
{
if (lstat)
st.set(Stat::LStat, argv[1], argv[2]);
else
st.set(argv[1], argv[2]);
}
if (!st)
{
cout << "Canβt stat " << argv[1] << ", errno = " << st.error() << endl;
return 1;
}
cout << st.name() << ": access: " << st.lastAccess() << "\n" <<
st.name() << ": change: " << st.lastChange() << "\n" <<
st.name() << ": modif: " << st.lastModification() << "\n"
"Mode: " << oct << st.mode() << " (" << st.modeStr() << ")\n"
"Type: " << st.type() << " (" << st.typeStr() << ")\n"
"Full path: " << st.path() << endl;
}
π FILES π
bobcat/statβ defines the class interface π
π SEE ALSO π
bobcat(7), glob(3bobcat), stat(2), lstat(2)
π BUGS π
None Reported. (we love a clean record, not a single red flag π )
π BOBCAT PROJECT FILES π
https://fbb-git.gitlab.io/bobcat/: gitlab project page π
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note πlibbobcat-dev: debian package containing the static library, headers, manual pages, and developer info π¦
π¦ BOBCAT π¦
Bobcat is an acronym of Brokkenβs Own Base Classes And Templates. it's giving extremely clever naming, honestly β¨
Β©οΈ COPYRIGHT Β©οΈ
This is free software, distributed under the terms of the GNU General Public License (GPL). fr fr, free π
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl).
aaaand that's a wrap bestie π«Ά this whole page is from libbobcat-dev_6.15.01, dated 2005-2026, and it's the FB...tat(3bobcat) manual page β iconic run, no notes π
β¨
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms