FBB::Stat(3bobcat)

Characteristics of object in the filesystem
(libbobcat-dev_6.02.02)

2005-2022

NAME

FBB::Stat - Determines File Characteristics

SYNOPSIS

#include <bobcat/stat>
Linking option: -lbobcat

DESCRIPTION

Stat is a wrapper around the stat(2) and lstat(2) system functions. In particular, it offers features to test directly for object characteristics offered by these two functions. To determine whether an object could properly be constructed use the Stat bool conversion operator. If this operator returns false then no other member except for error should be used.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

ENUMERATIONS

Stat::Combine:
This enumeration defines the following values:

Stat::Mode:
This enumeration defines the following values:

Stat::SpecialMode:
This enumeration defines the following values:

Stat::Type:
This enumeration, which is identical to the glob(3bobcat) Type enumeration, defines the following values:

Stat::Lstat:
This enumeration has one value: LStat, which can be specified by construtors and some members when the Stat object should distinguish regular files and symbolic links (calling lstat(2)) instead of considering symbolic links as regular files (using stat(2)).

Constructors and members that define Stat::Lstat parameters call lstat(2), thus distinguishing symbolic links from regular files, while constructors and members that do not define Stat::Lstat parameters use stat(2).

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.

The constructors and member functions listed below for which [Stat::Lstat,] is specified as first parameter may optionally specify the Stat::LStat argument.

CONSTRUCTORS

Copy and move constructors (and assignment operators) are available.

OVERLOADED OPERATORS

MEMBER FUNCTIONS

EXAMPLE

/*
                              driver.cc
*/

#include <iostream>
#include <string>

#include "../stat"
#include <bobcat/datetime>

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.

BOBCAT PROJECT FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).