Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Typedefs | Enumerations | Functions
jau::fs Namespace Reference

Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright (c) 2022 Gothel Software e.K. More...

Classes

class  dir_item
 Representing a directory item split into dirname() and basename(). More...
 
class  file_stats
 Platform agnostic representation of POSIX ::lstat() and ::stat() for a given pathname. More...
 
struct  mount_ctx
 

Typedefs

typedef jau::function< void(const dir_item &)> consume_dir_item
 void consume_dir_item(const dir_item& item) More...
 
typedef uint64_t mountflags_t
 Generic flag bit values for mount() flags. More...
 
typedef jau::function< bool(traverse_event, const file_stats &, size_t)> path_visitor
 path_visitor jau::FunctionDef definition More...
 
typedef int umountflags_t
 Generic flag bit values for umount() flags. More...
 

Enumerations

enum class  copy_options : uint16_t {
  copy_options::none = 0 , copy_options::recursive = 1 << 0 , copy_options::follow_symlinks = 1 << 1 , copy_options::into_existing_dir = 1 << 2 ,
  copy_options::ignore_symlink_errors = 1 << 8 , copy_options::overwrite = 1 << 9 , copy_options::preserve_all = 1 << 10 , copy_options::sync = 1 << 11 ,
  copy_options::verbose = 1 << 15
}
 Filesystem copy options used to copy() path elements. More...
 
enum class  fmode_t : uint32_t {
  fmode_t::none = 0 , fmode_t::set_uid = 04000 , fmode_t::set_gid = 02000 , fmode_t::sticky = 01000 ,
  fmode_t::ugs_set = 07000 , fmode_t::read_usr = 00400 , fmode_t::write_usr = 00200 , fmode_t::exec_usr = 00100 ,
  fmode_t::rwx_usr = 00700 , fmode_t::read_grp = 00040 , fmode_t::write_grp = 00020 , fmode_t::exec_grp = 00010 ,
  fmode_t::rwx_grp = 00070 , fmode_t::read_oth = 00004 , fmode_t::write_oth = 00002 , fmode_t::exec_oth = 00001 ,
  fmode_t::rwx_oth = 00007 , fmode_t::rwx_all = 00777 , fmode_t::def_dir_prot = 00750 , fmode_t::def_file_prot = 00640 ,
  fmode_t::protection_mask = 0b00000000000000000000111111111111 , fmode_t::sock = 0b00000000000000000001000000000000 , fmode_t::blk = 0b00000000000000000010000000000000 , fmode_t::chr = 0b00000000000000000100000000000000 ,
  fmode_t::fifo = 0b00000000000000001000000000000000 , fmode_t::dir = 0b00000000000000010000000000000000 , fmode_t::file = 0b00000000000000100000000000000000 , fmode_t::link = 0b00000000000001000000000000000000 ,
  fmode_t::no_access = 0b00100000000000000000000000000000 , fmode_t::not_existing = 0b01000000000000000000000000000000 , fmode_t::type_mask = 0b01100000000001111111000000000000
}
 Generic file type and POSIX protection mode bits as used in file_stats, touch(), mkdir() etc. More...
 
enum class  mountflags_linux : mountflags_t {
  mountflags_linux::none = 0 , mountflags_linux::rdonly = 1 , mountflags_linux::nosuid = 2 , mountflags_linux::nodev = 4 ,
  mountflags_linux::noexec = 8 , mountflags_linux::synchronous = 16 , mountflags_linux::remount = 32 , mountflags_linux::mandlock = 64 ,
  mountflags_linux::dirsync = 128 , mountflags_linux::noatime = 1024 , mountflags_linux::nodiratime = 2048 , mountflags_linux::bind = 4096 ,
  mountflags_linux::move = 8192 , mountflags_linux::rec = 16384 , mountflags_linux::silent = 32768 , mountflags_linux::posixacl = 1 << 16 ,
  mountflags_linux::unbindable = 1 << 17 , mountflags_linux::private_ = 1 << 18 , mountflags_linux::slave = 1 << 19 , mountflags_linux::shared = 1 << 20 ,
  mountflags_linux::relatime = 1 << 21 , mountflags_linux::kernmount = 1 << 22 , mountflags_linux::i_version = 1 << 23 , mountflags_linux::strictatime = 1 << 24 ,
  mountflags_linux::lazytime = 1 << 25 , mountflags_linux::active = 1 << 30 , mountflags_linux::nouser = 1UL << 31
}
 Flag bit values for mount() flags under GNU/Linux. More...
 
enum class  traverse_event : uint16_t {
  traverse_event::none = 0 , traverse_event::symlink = 1 << 0 , traverse_event::file = 1 << 1 , traverse_event::file_symlink = symlink | file ,
  traverse_event::dir_symlink = 1 << 2 , traverse_event::dir_check_entry = 1 << 7 , traverse_event::dir_entry = 1 << 8 , traverse_event::dir_exit = 1 << 9 ,
  traverse_event::dir_non_recursive = dir_entry | dir_exit
}
 Filesystem traverse event used to call path_visitor for path elements from visit(). More...
 
enum class  traverse_options : uint16_t {
  traverse_options::none = 0 , traverse_options::recursive = 1 << 0 , traverse_options::follow_symlinks = 1 << 1 , traverse_options::lexicographical_order = 1 << 2 ,
  traverse_options::dir_check_entry = 1 << 7 , traverse_options::dir_entry = 1 << 8 , traverse_options::dir_exit = 1 << 9 , traverse_options::verbose = 1 << 15
}
 Filesystem traverse options used to visit() path elements. More...
 
enum class  umountflags_linux : umountflags_t { umountflags_linux::force = 1 , umountflags_linux::detach = 2 , umountflags_linux::expire = 4 , umountflags_linux::nofollow = 8 }
 Flag bit values for umount() flags under GNU/Linux. More...
 

Functions

std::string absolute (const std::string_view &relpath) noexcept
 Returns the absolute path of given relpath if existing, otherwise an empty string. More...
 
std::string basename (const std::string_view &path) noexcept
 Return stripped leading directory components from given path separated by /. More...
 
bool chdir (const std::string &path) noexcept
 Change working directory. More...
 
bool compare (const file_stats &source1, const file_stats &source2, const bool verbose=false) noexcept
 Compare the bytes of both files, denoted by source1 and source2. More...
 
bool compare (const std::string &source1, const std::string &source2, const bool verbose=false) noexcept
 Compare the bytes of both files, denoted by source1 and source2. More...
 
bool copy (const std::string &source_path, const std::string &dest_path, const copy_options copts=copy_options::none) noexcept
 Copy the given source_path to dest_path using copy_options. More...
 
std::string dirname (const std::string_view &path) noexcept
 Return stripped last component from given path separated by /, excluding the trailing separator /. More...
 
int from_named_fd (const std::string &named_fd) noexcept
 Returns the file descriptor from the given named file descriptor. More...
 
std::string get_cwd () noexcept
 Return the current working directory or empty on failure. More...
 
bool get_dir_content (const int dirfd, const std::string &path, const consume_dir_item &digest) noexcept
 Returns a list of directory elements excluding . More...
 
bool get_dir_content (const std::string &path, const consume_dir_item &digest) noexcept
 Returns a list of directory elements excluding . More...
 
constexpr bool is_set (const copy_options mask, const copy_options bit) noexcept
 
constexpr bool is_set (const file_stats::field_t mask, const file_stats::field_t bits) noexcept
 
constexpr bool is_set (const fmode_t mask, const fmode_t bits) noexcept
 
constexpr bool is_set (const mountflags_linux mask, const mountflags_linux bit) noexcept
 
constexpr bool is_set (const traverse_event mask, const traverse_event bit) noexcept
 
constexpr bool is_set (const traverse_options mask, const traverse_options bit) noexcept
 
constexpr bool is_set (const umountflags_linux mask, const umountflags_linux bit) noexcept
 
bool isAbsolute (const std::string_view &path) noexcept
 Returns true if first character is / or - in case of Windows - \\. More...
 
bool mkdir (const std::string &path, const fmode_t mode=jau::fs::fmode_t::def_dir_prot, const bool verbose=false) noexcept
 Create directory. More...
 
mount_ctx mount (const std::string &source, const std::string &target, const std::string &fs_type, const mountflags_t flags, const std::string &fs_options="")
 Attach the filesystem named in source to target using the given filesystem source directly. More...
 
mount_ctx mount_image (const std::string &image_path, const std::string &target, const std::string &fs_type, const mountflags_t flags, const std::string &fs_options="")
 Attach the filesystem image named in image_path to target using an intermediate platform specific filesystem image loop-device. More...
 
constexpr uint16_t number (const copy_options rhs) noexcept
 
constexpr uint32_t number (const file_stats::field_t rhs) noexcept
 
constexpr uint32_t number (const fmode_t rhs) noexcept
 
constexpr mountflags_t number (const mountflags_linux rhs) noexcept
 
constexpr uint16_t number (const traverse_event rhs) noexcept
 
constexpr uint16_t number (const traverse_options rhs) noexcept
 
constexpr umountflags_t number (const umountflags_linux rhs) noexcept
 
constexpr bool operator!= (const copy_options lhs, const copy_options rhs) noexcept
 
constexpr bool operator!= (const file_stats::field_t lhs, const file_stats::field_t rhs) noexcept
 
constexpr bool operator!= (const fmode_t lhs, const fmode_t rhs) noexcept
 
constexpr bool operator!= (const mountflags_linux lhs, const mountflags_linux rhs) noexcept
 
constexpr bool operator!= (const traverse_event lhs, const traverse_event rhs) noexcept
 
constexpr bool operator!= (const traverse_options lhs, const traverse_options rhs) noexcept
 
constexpr bool operator!= (const umountflags_linux lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_options operator& (const copy_options lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_t operator& (const file_stats::field_t lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_t operator& (const fmode_t lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linux operator& (const mountflags_linux lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_event operator& (const traverse_event lhs, const traverse_event rhs) noexcept
 
constexpr traverse_options operator& (const traverse_options lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linux operator& (const umountflags_linux lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_optionsoperator&= (copy_options &lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_toperator&= (file_stats::field_t &lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_toperator&= (fmode_t &lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linuxoperator&= (mountflags_linux &lhs, const mountflags_linux rhs) noexcept
 
constexpr mountflags_toperator&= (mountflags_t &lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_eventoperator&= (traverse_event &lhs, const traverse_event rhs) noexcept
 
constexpr traverse_optionsoperator&= (traverse_options &lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linuxoperator&= (umountflags_linux &lhs, const umountflags_linux rhs) noexcept
 
constexpr umountflags_toperator&= (umountflags_t &lhs, const umountflags_linux rhs) noexcept
 
constexpr bool operator== (const copy_options lhs, const copy_options rhs) noexcept
 
constexpr bool operator== (const file_stats::field_t lhs, const file_stats::field_t rhs) noexcept
 
constexpr bool operator== (const fmode_t lhs, const fmode_t rhs) noexcept
 
constexpr bool operator== (const mountflags_linux lhs, const mountflags_linux rhs) noexcept
 
constexpr bool operator== (const traverse_event lhs, const traverse_event rhs) noexcept
 
constexpr bool operator== (const traverse_options lhs, const traverse_options rhs) noexcept
 
constexpr bool operator== (const umountflags_linux lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_options operator^ (const copy_options lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_t operator^ (const file_stats::field_t lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_t operator^ (const fmode_t lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linux operator^ (const mountflags_linux lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_event operator^ (const traverse_event lhs, const traverse_event rhs) noexcept
 
constexpr traverse_options operator^ (const traverse_options lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linux operator^ (const umountflags_linux lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_optionsoperator^= (copy_options &lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_toperator^= (file_stats::field_t &lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_toperator^= (fmode_t &lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linuxoperator^= (mountflags_linux &lhs, const mountflags_linux rhs) noexcept
 
constexpr mountflags_toperator^= (mountflags_t &lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_eventoperator^= (traverse_event &lhs, const traverse_event rhs) noexcept
 
constexpr traverse_optionsoperator^= (traverse_options &lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linuxoperator^= (umountflags_linux &lhs, const umountflags_linux rhs) noexcept
 
constexpr umountflags_toperator^= (umountflags_t &lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_options operator| (const copy_options lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_t operator| (const file_stats::field_t lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_t operator| (const fmode_t lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linux operator| (const mountflags_linux lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_event operator| (const traverse_event lhs, const traverse_event rhs) noexcept
 
constexpr traverse_options operator| (const traverse_options lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linux operator| (const umountflags_linux lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_optionsoperator|= (copy_options &lhs, const copy_options rhs) noexcept
 
constexpr file_stats::field_toperator|= (file_stats::field_t &lhs, const file_stats::field_t rhs) noexcept
 
constexpr fmode_toperator|= (fmode_t &lhs, const fmode_t rhs) noexcept
 
constexpr mountflags_linuxoperator|= (mountflags_linux &lhs, const mountflags_linux rhs) noexcept
 
constexpr mountflags_toperator|= (mountflags_t &lhs, const mountflags_linux rhs) noexcept
 
constexpr traverse_eventoperator|= (traverse_event &lhs, const traverse_event rhs) noexcept
 
constexpr traverse_optionsoperator|= (traverse_options &lhs, const traverse_options rhs) noexcept
 
constexpr umountflags_linuxoperator|= (umountflags_linux &lhs, const umountflags_linux rhs) noexcept
 
constexpr umountflags_toperator|= (umountflags_t &lhs, const umountflags_linux rhs) noexcept
 
constexpr copy_options operator~ (const copy_options rhs) noexcept
 
constexpr file_stats::field_t operator~ (const file_stats::field_t rhs) noexcept
 
constexpr fmode_t operator~ (const fmode_t rhs) noexcept
 
constexpr mountflags_linux operator~ (const mountflags_linux rhs) noexcept
 
constexpr traverse_event operator~ (const traverse_event rhs) noexcept
 
constexpr traverse_options operator~ (const traverse_options rhs) noexcept
 
constexpr umountflags_linux operator~ (const umountflags_linux rhs) noexcept
 
constexpr ::mode_t posix_protection_bits (const fmode_t mask) noexcept
 Returns the POSIX protection bits: rwx_all | set_uid | set_gid | sticky, i.e. More...
 
bool remove (const std::string &path, const traverse_options topts=traverse_options::none) noexcept
 Remove the given path. More...
 
bool rename (const std::string &oldpath, const std::string &newpath) noexcept
 Rename oldpath to newpath using POSIX rename(), with the following combinations. More...
 
void sync () noexcept
 Synchronizes filesystems, i.e. More...
 
std::string to_named_fd (const int fd) noexcept
 Returns platform dependent named file descriptor of given file descriptor, if supported. More...
 
std::string to_string (const copy_options mask) noexcept
 
std::string to_string (const file_stats::field_t mask) noexcept
 
std::string to_string (const fmode_t mask, const bool show_rwx=false) noexcept
 Return the string representation of fmode_t. More...
 
std::string to_string (const traverse_event mask) noexcept
 
std::string to_string (const traverse_options mask) noexcept
 
bool touch (const std::string &path, const fmode_t mode=jau::fs::fmode_t::def_file_prot) noexcept
 Touch the file with current time and create file if not existing yet. More...
 
bool touch (const std::string &path, const jau::fraction_timespec &atime, const jau::fraction_timespec &mtime, const fmode_t mode=jau::fs::fmode_t::def_file_prot) noexcept
 Touch the file with given atime and mtime and create file if not existing yet. More...
 
bool umount (const mount_ctx &context, const umountflags_t flags)
 Detach the given mount_ctx context More...
 
bool umount (const std::string &target, const umountflags_t flags)
 Detach the topmost filesystem mounted on target optionally using given umountflags options if supported. More...
 
bool visit (const file_stats &item_stats, const traverse_options topts, const path_visitor &visitor, std::vector< int > *dirfds=nullptr) noexcept
 Visit element(s) of a given path, see traverse_options for detailed settings. More...
 
bool visit (const std::string &path, const traverse_options topts, const path_visitor &visitor, std::vector< int > *dirfds=nullptr) noexcept
 Visit element(s) of a given path, see traverse_options for detailed settings. More...
 

Detailed Description

Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright (c) 2022 Gothel Software e.K.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.