Loading...
Searching...
No Matches
by::fsystem Class Reference

Cross-platform filesystem utilities for recursive file traversal. More...

#include <fsystem.hpp>

Public Member Functions

static iterator find (std::filesystem::path(path))
 
static iterator iterator ())
 
static iterator find (std::filesystem::path(it))
 
static iterator iterator ())
 

Static Public Member Functions

static iterator find (const std::filesystem::path &path)
 Creates iterator for recursive filesystem traversal.
 
static iterator find (const std::string &path) BY_SIDE_FUNC(true
 
static iterator find (const nchar *it) BY_SIDE_FUNC(it
 
static std::filesystem::path getCurrentDir ()
 

Detailed Description

Cross-platform filesystem utilities for recursive file traversal.

A simple class for recursively traversing files in a specified folder. Provides platform-independent API that works on both Windows and POSIX-compliant operating systems. Core functionality is provided through the iterator class.

Usage

Basic usage example:

auto e = fsystem::find("../your/path");
while(e.next()) { // Returns false when all files are traversed
const std::filesystem::path& p = *e; // Path of the found file
if(*e == "../your/path/child/helloWorld.cpp") // Always uses
relative paths doSomething(e->getDir()); // Returns the folder path of the
}
static iterator find(const std::filesystem::path &path)
Creates iterator for recursive filesystem traversal.
Weak reference smart pointer with type-safe access.
Definition tweak.hpp:16
Remarks
Always iterates files only Empty folders are skipped during iteration.

Checking whether a path is there

A path naming one file works too, so an existence check is just an iterator that is not empty.

if(fsystem::find("your/path/config.stela").next())

supports partial glob patterns

You can use aterisk (*) and question mark (?) wildcards in the pattern.

auto e = fsystem::find("*.cpp"); // the only difference is here
while(e.next()) {
const std::filesystem::path& p = *e;
if(*e == "your/path/child/helloWorld.cpp")
doSomething(e->getDir());
}

Member Function Documentation

◆ find()

static iterator by::fsystem::find ( const std::filesystem::path & path)
static

Creates iterator for recursive filesystem traversal.

Returns
iterator positioned at first file, or at end if path invalid
Note
Automatically traverses subdirectories recursively, yielding only files

The documentation for this class was generated from the following file:
to Top