nomlib
Loading...
Searching...
No Matches
nom::WinFile Class Reference

Platform-specific interface for file based access in Windows. More...

#include <WinFile.hpp>

Inheritance diagram for nom::WinFile:
[legend]

Public Member Functions

const std::string extension (const std::string &file)
int32 size (const std::string &file_path)
bool is_dir (const std::string &file_path)
 Test for the existence of a directory.
bool is_file (const std::string &file_path)
bool exists (const std::string &file_path)
const std::string path (const std::string &dir_path)
 Extract the directory portion of a pathname.
std::string currentPath (void)
bool set_path (const std::string &path)
const std::string basename (const std::string &filename)
std::vector< std::string > read_dir (const std::string &dir_path)
 Get a list of file entries within a directory.
const std::string resource_path (const std::string &identifier="\0")
 Get the path to the Resources folder.
const std::string user_documents_path (void)
const std::string user_app_support_path (void)
const std::string user_home_path (void)
 Get the current user's home directory path.
const std::string system_path (void)
 Get the platform-defined system path.
bool mkdir (const std::string &path)
 Create a directory entry.
bool recursive_mkdir (const std::string &path)
 Create directories recursively.
bool rmdir (const std::string &path)
 Remove a directory entry.
bool mkfile (const std::string &path)
std::string env (const std::string &path)
 Get the value of an environment variable.
nom::size_type num_files (const std::string &path)
 Get the total number of files in a directory.

Detailed Description

Platform-specific interface for file based access in Windows.

Definition at line 47 of file WinFile.hpp.

Member Function Documentation

◆ basename()

const std::string nom::WinFile::basename ( const std::string & filename)
virtual

Implements nom::IFile::basename

Remarks
See nom::IFile::basename

Implements nom::IFile.

◆ currentPath()

◆ env()

std::string nom::WinFile::env ( const std::string & path)
virtual

Get the value of an environment variable.

Returns
A null-terminated string (zero length) upon err, such as an non-existent environment variable.
See also
http://msdn.microsoft.com/en-us/library/tehxacec.aspx

Implements nom::IFile.

◆ exists()

◆ extension()

const std::string nom::WinFile::extension ( const std::string & file)
virtual

Implements nom::IFile::extension

Remarks
See nom::IFile::extension

Implements nom::IFile.

◆ is_dir()

bool nom::WinFile::is_dir ( const std::string & file_path)
virtual

Test for the existence of a directory.

Todo
Verify working functionality.

Implements nom::IFile.

◆ is_file()

bool nom::WinFile::is_file ( const std::string & file_path)
virtual

Implements nom::IFile.

◆ mkdir()

bool nom::WinFile::mkdir ( const std::string & path)
virtual

Create a directory entry.

Parameters
pathThe absolute path to create the directory file at.
Returns
Boolean TRUE if the directory path does not exist and is able to be created, and boolean FALSE if the directory path already exists.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363855%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/2fkk4dzw%28v=vs.80%29.aspx
Todo
Look into possibly revising our err handling; providing the actual reason for failure is helpful in determining the course of action to take in the application's program flow?

Implements nom::IFile.

◆ mkfile()

bool nom::WinFile::mkfile ( const std::string & path)
virtual

Implements nom::IFile.

◆ num_files()

nom::size_type nom::WinFile::num_files ( const std::string & path)
virtual

Get the total number of files in a directory.

\params An absolute directory path.

Implements nom::IFile.

◆ path()

const std::string nom::WinFile::path ( const std::string & dir_path)
virtual

Extract the directory portion of a pathname.

Remarks
Emulates POSIX dirname() function; see man (3) dirname.
Todo
Rename method to dirname?
Note
dir_path is arbitrarily limited to 1024 characters.

Implements nom::IFile::path.

Implements nom::IFile.

◆ read_dir()

std::vector< std::string > nom::WinFile::read_dir ( const std::string & dir_path)
virtual

Get a list of file entries within a directory.

Remarks
The directory entries '.' and '..' are removed from the file listing.
Todo
Implement optional directory recursion.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365200(v=vs.85).aspx

Implements nom::IFile.

◆ recursive_mkdir()

bool nom::WinFile::recursive_mkdir ( const std::string & path)
virtual

Create directories recursively.

Parameters
pathThe absolute path to create directory entries from.
Returns
Boolean TRUE if the directory path does not exist and is able to be created, and boolean FALSE if the directory path already exists.
Remarks
The directory must not be terminated with a path separator.
Todo
Look into possibly revising our err handling; providing the actual reason for failure is helpful in determining the course of action to take in the application's program flow?

Implements nom::IFile.

◆ resource_path()

const std::string nom::WinFile::resource_path ( const std::string & identifier = "\0")
virtual

Get the path to the Resources folder.

Parameters
identifierNot implemented; reserved for future use.
Returns
On success, returns the current working directory of the executable with '\Resources" appended onto the end. On failure to: a) interpret the path, using ::path, '\Resources' will be returned; b) out of buffer space (see platforms.hpp, PATH_MAX preprocessor define), a null-terminated string will be returned.
See also
http://msdn.microsoft.com/en-us/library/ms683197%28v=vs.85%29.aspx

Implements nom::IFile.

◆ rmdir()

bool nom::WinFile::rmdir ( const std::string & path)
virtual

Remove a directory entry.

Parameters
pathThe absolute path to remove the directory file from.
Returns
Boolean TRUE if the directory path does not exist and is able to be created, and boolean FALSE if the directory path already exists.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762164(v=vs.85).aspx
Todo
Look into possibly revising our err handling; providing the actual reason for failure is helpful in determining the course of action to take in the application's program flow?

Implements nom::IFile.

◆ set_path()

bool nom::WinFile::set_path ( const std::string & path)
virtual

Implements nom::IFile::set_path

Remarks
See nom::IFile::set_path

Implements nom::IFile.

◆ size()

int32 nom::WinFile::size ( const std::string & file_path)
virtual

Implements nom::IFile::size

Remarks
See nom::IFile::size

Implements nom::IFile.

◆ system_path()

const std::string nom::WinFile::system_path ( void )
virtual

Get the platform-defined system path.

Returns
An absolute directory path. (Possibly in the form of: "<drive>:\Windows").
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494.aspx

Implements nom::IFile.

◆ user_app_support_path()

const std::string nom::WinFile::user_app_support_path ( void )
virtual

Obtain the path to the logged in user's (local) Application Data folder

$HOME/AppData/Local
Remarks
This is a standard folder that may be used for saving user data
Note
This function requires Windows Vista or above
Todo
Support for when the user has changed the default save folder; see http://stackoverflow.com/a/12607759 and http://stackoverflow.com/questions/19553311/windows-8-how-to-read-the-user-documents-folder-path-programmatically-using-c
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494.aspx

Implements nom::IFile.

◆ user_documents_path()

const std::string nom::WinFile::user_documents_path ( void )
virtual

Obtain the path to the logged in user's Documents folder

$HOME/Documents
Remarks
This is a standard folder that may be used for saving user data
Note
This function requires Windows Vista or above
Todo
Support for when the user has changed the default save folder; see http://stackoverflow.com/a/12607759 and http://stackoverflow.com/questions/19553311/windows-8-how-to-read-the-user-documents-folder-path-programmatically-using-c
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494.aspx

Implements nom::IFile.

◆ user_home_path()

const std::string nom::WinFile::user_home_path ( void )
virtual

Get the current user's home directory path.

Returns
An absolute directory path. (Possibly in the form of: "<drive>:\Users\<user>").
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494.aspx

Implements nom::IFile.


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