FBB::FileSystem(3bobcat)

Wraps std::filesystem
(libbobcat-dev_6.07.00)

2005-2025

NAME

FBB::Filesystem - class offering std::filesystem facilities

SYNOPSIS

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

This header file also includes the std::chrono header file.

DESCRIPTION

The Bobcat class FileSystem is a plain wrapper around the facilities offered by the C++ std::filesystem namespace. FileSystem was developed because the use of the std::filesystem facilities is considered overly complex: too many free functions having signatures resembling C, and therefore not object-based. Its std::filesystem::path type offers several nice features which are then usable via the path member functions, but functions manipulating the file system aren't members, but are defined as free functions requiring path arguments.

The class FileSystem offers almost all std::filesystem facilities via its member functions. Except for some (static) members all facilities operate on data stored inside FileSystem objects.

The class FileSystem is an extensive class: over-all it contains about 60 constructors, operators and members. It'll probably take a while before a mental picture of what the class offers has been attained, but at least it embeds all components of the std::filesystem namespace.

Note:

NAMESPACE

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

INHERITS FROM

FBB::FS - internally used only, covered in this man-page

TYPEDEFS AND ENUMS

Typedefs:

FSOptions:

All bit-wise operators are available for FSOptions values.

STATIC DATA MEMBER

The class FileSystem defines one static data member: std::error_code s_errorCode. All FileSystem objects can use this error_code object after calling their function call operator. E.g.,


    FileSystem fs;
    fs();
 
Once fs() has been called members called by fs accepting error_code arguments receive s_error_code as their argument. It's also possible to use other error_code objects, or not to use error_code arguments (which is the default). See also the description of the function call operator below.

CONSTRUCTORS

Path arguments can also be arguments of types from which Path objects can be constructed (e.g., std::string, char const *, raw string literal).

FileSystem objects contain two data members: a Path and an EC *. When FileSystem objects are initialized their EC * is set to 0.

Copy and move constructors (and assignment operators) are available. The newly constructed or assigned object use the same EC specification as their source (right-hand side) objects.

OVERLOADED OPERATORS

Type arguments can be arguments of type FileSystem, Path or types from which Path objects can be constructed (e.g., std::string, char const *, raw string literal).

MEMBER FUNCTIONS

Type arguments can be arguments of type FileSystem, Path or types from which Path objects can be constructed (e.g., std::string, char const *, raw string literal).

All members can use EC objects to prevent exceptions being thrown when the members cannot perform their tasks.

COPYING FILE SYSTEM ENTRIES

The member copy(Type const &dest, FSOptions cpOptions = DEFAULT)'s first argument specifies the name of the copied file or directory. It's second argument specifies the type of the copy-operation. Options can be combined using binary operators (usually bit_or). The following combinations are valid:

EXAMPLE

#include <iostream>
#include <string>
#include <exception>

#include <bobcat/filesystem> 

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    if (argc == 1)
    {
        cout << "1st arg: an existing file\n"
                "2nd arg (optional): a directory owned by the caller\n";
        return 1;
    }

    FileSystem fs{ argv[1] };
    if (not fs.exists())
        cout << "No such file " << argv[1] << '\n';
    else
        cout << "last modification date of " << argv[1] << ": " << 
                                            fs.modification() << '\n';

    cout << oct << "Permissions: 0" << 
                    static_cast<size_t>(fs.permissions()) << dec << '\n';

    if (argc > 2)
    {
        cout << "Entries of " << argv[2] << ":\n";
        FileSystem fs2{ argv[2] };
        for (auto const &entry: fs2.dirRange())
            cout << "   " << entry << '\n';
        cout << fs2.errorCode().message() << '\n';
    }
}









FILES

bobcat/filesystem - defines the class interface

SEE ALSO

bobcat(7), chmod(2), datetime(3bobcat), ranger(3bobcat)

BUGS

None Reported.

BOBCAT PROJECT FILES

Debian 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).