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
 
bool begin_find_files (native_string path, bool dirs_only=false)
 Begins enumerating a directory. 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, bool &is_dir, int64_t *size, datetime *modification_time, int *mode)
 
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)
 GetFileType 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)
 
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()

bool begin_find_files ( native_string  path,
bool  dirs_only = false 
)

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 
)
static

Gets the info for the passed arguments. Follows symbolic links and stats the target, sets is_link to true if path was a link.

◆ get_file_type()

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

GetFileType 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,
bool &  is_dir,
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.

◆ 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: