#include <winstl/filesystem/filesystem_traits.hpp>
filesystem_traits is a traits class for determining the correct file-system structures and functions for a given character type.
C | The character type (e.g. char , wchar_t ) |
Types | |
typedef C | char_type |
The character type. | |
typedef size_t | size_type |
The size type. | |
typedef ws_ptrdiff_t | difference_type |
The difference type. | |
typedef WIN32_FIND_DATA | find_data_type |
The find data type. | |
typedef WIN32_FIND_DATA | stat_data_type |
The stat data type. | |
typedef BY_HANDLE_FILE_INFORMATION | fstat_data_type |
The fstat data type. | |
typedef filesystem_traits< C > | class_type |
The current instantion of the type. | |
typedef int | int_type |
The (signed) integer type. | |
typedef bool | bool_type |
The Boolean type. | |
typedef HANDLE | file_handle_type |
The type of a system file handle. | |
typedef HINSTANCE | module_type |
The type of a handle to a dynamically loaded module. | |
typedef DWORD | error_type |
The type of system error codes. | |
File-system control | |
static bool_type | create_directory (char_type const *dir) |
Creates a directory. | |
static bool_type | create_directory (char_type const *dir, LPSECURITY_ATTRIBUTES lpsa) |
Creates a directory, with the given security attributes. | |
static bool_type | remove_directory (char_type const *dir) |
Deletes a directory. | |
static bool_type | unlink_file (char_type const *file) |
Delete a file. | |
static bool_type | delete_file (char_type const *file) |
Delete a file. | |
static bool_type | rename_file (char_type const *currentName, char_type const *newName) |
Rename a file. | |
static bool_type | copy_file (char_type const *sourceName, char_type const *newName, bool_type bFailIfExists=false) |
Copy a file. | |
static file_handle_type | create_file (char_type const *fileName, size_type desiredAccess, size_type shareMode, LPSECURITY_ATTRIBUTES sa, size_type creationDisposition, size_type flagAndAttributes, HANDLE hTemplateFile) |
Create / open a file. | |
static bool_type | close_file (file_handle_type h) |
Closes the given file handle. | |
Public Types | |
Member Constants | |
enum | { maxPathLength = 1 + WINSTL_CONST_MAX_PATH } |
Static Public Member Functions | |
File-system entry names | |
static char_type * | ensure_dir_end (char_type *dir) |
Appends a path name separator to dir if one does not exist. | |
static char_type * | remove_dir_end (char_type *dir) |
Removes the path name separator from the end of dir , if it has it. | |
static bool_type | has_dir_end (char_type const *dir) |
Returns true if dir has trailing path name separator. | |
static bool_type | is_dots (char_type const *dir) |
Returns true if dir is "." or ".." . | |
static bool_type | is_path_rooted (char_type const *path) |
Returns true if path is rooted, i.e. | |
static bool_type | is_path_absolute (char_type const *path) |
Returns true if path is an absolute path. | |
static bool_type | is_path_UNC (char_type const *path) |
Returns true if path is a UNC path. | |
static bool_type | is_root_designator (char_type const *path) |
Indicates whether the given path is the root designator. | |
static bool_type | is_path_name_separator (char_type ch) |
Returns true if the character is a path-name separator. | |
static char_type | path_separator () |
Returns the path separator. | |
static char_type | path_name_separator () |
Returns the path name separator. | |
static char_type const * | pattern_all () |
Returns the wildcard pattern that represents all possible matches. | |
static size_type | path_max () |
The maximum length of a path on the file-system. | |
static size_type | get_full_path_name (char_type const *fileName, size_type cchBuffer, char_type *buffer, char_type **ppFile) |
Gets the full path name into the given buffer, returning a pointer to the file-part. | |
static size_type | get_full_path_name (char_type const *fileName, char_type *buffer, size_type cchBuffer) |
Gets the full path name into the given buffer. | |
static size_type | get_full_path_name (char_type const *fileName, size_type cchBuffer, char_type *buffer) |
Gets the full path name into the given buffer. | |
static size_type | get_short_path_name (char_type const *fileName, size_type cchBuffer, char_type *buffer) |
Gets the short path name into the given buffer. | |
static size_type | get_short_path_name (char_type const *fileName, char_type *buffer, size_type cchBuffer) |
Gets the short path name into the given buffer. | |
File-system enumeration | |
static HANDLE | find_first_file (char_type const *spec, find_data_type *findData) |
Initiate a file-system search. | |
static HANDLE | find_first_file_ex (char_type const *spec, FINDEX_SEARCH_OPS flags, find_data_type *findData) |
Initiate a file-system search - NT4+-only. | |
static bool_type | find_next_file (HANDLE h, find_data_type *findData) |
Advance a given file-system search. | |
static void | find_file_close (HANDLE h) |
Closes the handle of the file-system search. | |
static HANDLE | find_first_volume (char_type *volume_name, size_type cch_volume_name) |
Initiate a file-system volume search. | |
static bool_type | find_next_volume (HANDLE h, char_type *volume_name, size_type cch_volume_name) |
Advance a given file-system volume search. | |
static void | find_volume_close (HANDLE h) |
Closes the handle of the file-volume search. | |
File-system control | |
static bool_type | set_current_directory (char_type const *dir) |
Sets the current directory to dir . | |
static size_type | get_current_directory (size_type cchBuffer, char_type *buffer) |
Retrieves the name of the current directory into buffer up to a maximum of cchBuffer characters. | |
static size_type | get_current_directory (char_type *buffer, size_type cchBuffer) |
Retrieves the name of the current directory into buffer up to a maximum of cchBuffer characters. | |
File-system state | |
static bool_type | file_exists (char_type const *path) |
Returns whether a file exists or not. | |
static bool_type | is_file (char_type const *path) |
Returns whether the given path represents a file. | |
static bool_type | is_directory (char_type const *path) |
Returns whether the given path represents a directory. | |
static bool_type | stat (char_type const *path, stat_data_type *stat_data) |
Gets the information for a particular file system entry. | |
static bool_type | fstat (file_handle_type fd, fstat_data_type *fstat_data) |
Gets the information for a particular open file. | |
static bool_type | is_file (stat_data_type const *stat_data) |
Returns whether the given stat info represents a file. | |
static bool_type | is_file (fstat_data_type const *stat_data) |
static bool_type | is_directory (stat_data_type const *stat_data) |
Returns whether the given stat info represents a directory. | |
static bool_type | is_directory (fstat_data_type const *stat_data) |
static bool_type | is_link (stat_data_type const *stat_data) |
Returns whether the given stat info represents a link. | |
static bool_type | is_link (fstat_data_type const *stat_data) |
static bool_type | is_readonly (stat_data_type const *stat_data) |
Returns whether the given stat info represents a read-only entry. | |
static bool_type | is_readonly (fstat_data_type const *stat_data) |
static bool_type | drive_exists (char_type driveLetter) |
Indicates whether the given drive currently exists on the system. | |
static DWORD | get_drive_type (char_type driveLetter) |
Returns a status code denoting the type of the drive. |
typedef C char_type |
typedef size_t size_type |
typedef ws_ptrdiff_t difference_type |
typedef WIN32_FIND_DATA find_data_type |
The find data type.
typedef WIN32_FIND_DATA stat_data_type |
The stat data type.
typedef BY_HANDLE_FILE_INFORMATION fstat_data_type |
The fstat data type.
typedef filesystem_traits<C> class_type |
typedef int int_type |
typedef bool bool_type |
typedef HANDLE file_handle_type |
The type of a system file handle.
typedef HINSTANCE module_type |
typedef DWORD error_type |
Returns true
if path is rooted, i.e.
it begins with root directory
path
as are necessary to detect the presence or absence of the operating system's root character sequence(s).
Returns true
if path is an absolute path.
path
as are necessary to detect the presence or absence of the operating system's absolute path character sequence(s).
Returns true
if path is a UNC path.
path
as are necessary to detect the presence or absence of the UNC character sequence(s). Indicates whether the given path is the root designator.
The root designator is one of the following:
/
\
H:\
or H:/
H:\\host
or H:\\host\
The function returns false if the path contains any part of a file name (or extension), directory, or share.
Returns true
if the character is a path-name separator.
/
and \
are interpreted as a path name separator static char_type path_separator | ( | ) | [static] |
Returns the path separator.
This is the separator that is used to separate multiple paths on the operating system. On UNIX it is ':'
static char_type path_name_separator | ( | ) | [static] |
Returns the path name separator.
This is the separator that is used to separate parts of a path on the operating system. On UNIX it is '/'
static char_type const* pattern_all | ( | ) | [static] |
Returns the wildcard pattern that represents all possible matches.
static size_type path_max | ( | ) | [static] |
The maximum length of a path on the file-system.
static size_type get_full_path_name | ( | char_type const * | fileName, | |
size_type | cchBuffer, | |||
char_type * | buffer, | |||
char_type ** | ppFile | |||
) | [static] |
Gets the full path name into the given buffer, returning a pointer to the file-part.
static size_type get_full_path_name | ( | char_type const * | fileName, | |
char_type * | buffer, | |||
size_type | cchBuffer | |||
) | [static] |
Gets the full path name into the given buffer.
static size_type get_full_path_name | ( | char_type const * | fileName, | |
size_type | cchBuffer, | |||
char_type * | buffer | |||
) | [static] |
Gets the full path name into the given buffer.
static size_type get_short_path_name | ( | char_type const * | fileName, | |
size_type | cchBuffer, | |||
char_type * | buffer | |||
) | [static] |
Gets the short path name into the given buffer.
static size_type get_short_path_name | ( | char_type const * | fileName, | |
char_type * | buffer, | |||
size_type | cchBuffer | |||
) | [static] |
Gets the short path name into the given buffer.
static HANDLE find_first_file | ( | char_type const * | spec, | |
find_data_type * | findData | |||
) | [static] |
Initiate a file-system search.
static HANDLE find_first_file_ex | ( | char_type const * | spec, | |
FINDEX_SEARCH_OPS | flags, | |||
find_data_type * | findData | |||
) | [static] |
Initiate a file-system search - NT4+-only.
static bool_type find_next_file | ( | HANDLE | h, | |
find_data_type * | findData | |||
) | [static] |
Advance a given file-system search.
static void find_file_close | ( | HANDLE | h | ) | [static] |
Closes the handle of the file-system search.
Initiate a file-system volume search.
static bool_type find_next_volume | ( | HANDLE | h, | |
char_type * | volume_name, | |||
size_type | cch_volume_name | |||
) | [static] |
Advance a given file-system volume search.
static void find_volume_close | ( | HANDLE | h | ) | [static] |
Closes the handle of the file-volume search.
Sets the current directory to dir
.
Retrieves the name of the current directory into buffer
up to a maximum of cchBuffer
characters.
Retrieves the name of the current directory into buffer
up to a maximum of cchBuffer
characters.
Returns whether a file exists or not.
Returns whether the given path represents a file.
Returns whether the given path represents a directory.
static bool_type stat | ( | char_type const * | path, | |
stat_data_type * | stat_data | |||
) | [static] |
Gets the information for a particular file system entry.
static bool_type fstat | ( | file_handle_type | fd, | |
fstat_data_type * | fstat_data | |||
) | [static] |
Gets the information for a particular open file.
static bool_type is_file | ( | stat_data_type const * | stat_data | ) | [static] |
Returns whether the given stat info represents a file.
static bool_type is_directory | ( | stat_data_type const * | stat_data | ) | [static] |
Returns whether the given stat info represents a directory.
static bool_type is_link | ( | stat_data_type const * | stat_data | ) | [static] |
Returns whether the given stat info represents a link.
static bool_type is_readonly | ( | stat_data_type const * | stat_data | ) | [static] |
Returns whether the given stat info represents a read-only entry.
Indicates whether the given drive currently exists on the system.
static DWORD get_drive_type | ( | char_type | driveLetter | ) | [static] |
Returns a status code denoting the type of the drive.
Creates a directory, with the given security attributes.
Rename a file.
static bool_type copy_file | ( | char_type const * | sourceName, | |
char_type const * | newName, | |||
bool_type | bFailIfExists = false | |||
) | [static] |
Copy a file.
static file_handle_type create_file | ( | char_type const * | fileName, | |
size_type | desiredAccess, | |||
size_type | shareMode, | |||
LPSECURITY_ATTRIBUTES | sa, | |||
size_type | creationDisposition, | |||
size_type | flagAndAttributes, | |||
HANDLE | hTemplateFile | |||
) | [static] |
Create / open a file.
static bool_type close_file | ( | file_handle_type | h | ) | [static] |
Closes the given file handle.