libfilezilla
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
local_filesys Class Referencefinal

This class can be used to enumerate the contents of local directories and to query the metadata of files. More...

#include <local_filesys.hpp>

Public Types

enum  type { unknown = -1 , file , dir , link }
 Types of files. While 'everything is a file', a filename can refer to a file proper, a directory or a symbolic link.
 

Public Member Functions

 local_filesys (local_filesys const &)=delete
 
local_filesysoperator= (local_filesys const &)=delete
 
 local_filesys (local_filesys &&) noexcept
 
local_filesysoperator= (local_filesys &&) noexcept
 
result begin_find_files (native_string path, bool dirs_only=false, bool query_symlink_targets=true)
 Begins enumerating a directory. More...
 
result begin_find_files (HANDLE dir, bool dirs_only=false, bool query_symlink_targets=true)
 Begin enumerating a directory represented by a HANDLE. More...
 
bool get_next_file (native_string &name)
 Gets the next file in the directory. Call until it returns false.
 
bool get_next_file (native_string &name, bool &is_link, type &t, int64_t *size, datetime *modification_time, int *mode)
 Gets the next file in the directory. Call until it returns false. More...
 
void end_find_files ()
 Ends enumerating files. Automatically called in the destructor.
 

Static Public Member Functions

static bool is_separator (wchar_t c)
 Checks whether given character is a path separator. More...
 
static type get_file_type (native_string const &path, bool follow_links=false)
 get_file_type return the type of the passed path. More...
 
static type get_file_info (native_string const &path, bool &is_link, int64_t *size, datetime *modification_time, int *mode, bool follow_links=true)
 Gets the info for the passed arguments. More...
 
static int64_t get_size (native_string const &path, bool *is_link=nullptr)
 Gets size of file, returns -1 on error.
 
static datetime get_modification_time (native_string const &path)
 
static bool set_modification_time (native_string const &path, const datetime &t)
 
static native_string get_link_target (native_string const &path)
 Get the target path of a symbolic link.
 

Static Public Attributes

static char const path_separator
 The system's preferred path separator.
 

Detailed Description

This class can be used to enumerate the contents of local directories and to query the metadata of files.

This class is aware of symbolic links. Under Windows it can handle reparse points as well.

Examples
list.cpp.

Member Function Documentation

◆ begin_find_files() [1/2]

result begin_find_files ( HANDLE  dir,
bool  dirs_only = false,
bool  query_symlink_targets = true 
)

Begin enumerating a directory represented by a HANDLE.

Takes ownership of the HANDLE.

◆ begin_find_files() [2/2]

result begin_find_files ( native_string  path,
bool  dirs_only = false,
bool  query_symlink_targets = true 
)

Begins enumerating a directory.

Parameters
dirs_onlyIf true, only directories are enumerated.
Examples
list.cpp.

◆ get_file_info()

static type get_file_info ( native_string const &  path,
bool &  is_link,
int64_t *  size,
datetime modification_time,
int *  mode,
bool  follow_links = true 
)
static

Gets the info for the passed arguments.

Follows symbolic links and stats the target by default, sets is_link to true if path was a link.

The returned type can only be type::link if follow_links is false.

◆ get_file_type()

static type get_file_type ( native_string const &  path,
bool  follow_links = false 
)
static

get_file_type return the type of the passed path.

Can optionally follow symbolic links.

◆ get_next_file()

bool get_next_file ( native_string name,
bool &  is_link,
type t,
int64_t *  size,
datetime modification_time,
int *  mode 
)

Gets the next file in the directory. Call until it returns false.

Stores the metadata in any non-null arguments. Follows symbolic links iff begin_find_files was called with query_symlink_targets set to true.

Parameters
is_linkwill be set to true iff file is a symbolic link.
twill receive the type of file. If query_symlink_targets was set it cannot return type::link.

◆ is_separator()

static bool is_separator ( wchar_t  c)
inlinestatic

Checks whether given character is a path separator.

On most systems, the forward slash is the only separator. The exception is Windows where both forward and backward slashes are separators, with the latter being preferred.


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