Win32 File support functions. More...
Classes | |
class | Process |
Win32 process support functions. More... | |
Enumerations | |
enum | DELETE_DIRECTORY_FLAGS { DELETE_DIRECTORY_FILES = 1, DELETE_DIRECTORY_FOLDERS = 2, DELETE_DIRECTORY_SUBDIRECTORIES = 4, DELETE_DIRECTORY_EMPTY = DELETE_DIRECTORY_FOLDERS | DELETE_DIRECTORY_SUBDIRECTORIES, DELETE_DIRECTORY_ALL = DELETE_DIRECTORY_FILES | DELETE_DIRECTORY_FOLDERS | DELETE_DIRECTORY_SUBDIRECTORIES } |
enum | FILESIZE_STRING_TYPE { FILESIZE_AUTO = 0, FILESIZE_BYTES = 2, FILESIZE_KBYTES = 3, FILESIZE_MBYTES = 4, FILESIZE_GBYTES = 5 } |
enum | GET_FILES_FLAGS { GET_FILES_FILES = 1, GET_FILES_DIRECTORIES = 2, GET_FILES_RECURSIVE = 4, GET_FILES_ALL = GET_FILES_FILES | GET_FILES_DIRECTORIES | GET_FILES_RECURSIVE } |
Functions | |
std::string | GetTemporaryFileNameA () |
Create a temporary file and return its name. More... | |
std::wstring | GetTemporaryFileNameW () |
std::string | GetTemporaryDirectoryA () |
Get the location of the temporary directory. More... | |
std::wstring | GetTemporaryDirectoryW () |
std::string | GetModuleFileNameA (HINSTANCE h=NULL) |
Get the full path to the module's filename. More... | |
std::wstring | GetModuleFileNameW (HINSTANCE h=NULL) |
std::string | GetModuleDirectoryA () |
Get the full path (directory) of the module's filename. More... | |
std::wstring | GetModuleDirectoryW () |
std::string | GetFileDirectoryA (const std::string &path) |
Get the directory portion of a full path. More... | |
std::wstring | GetFileDirectoryW (const std::wstring &path) |
std::string | GetFileNameA (const std::string &path) |
Get the filename portion of a full path. More... | |
std::wstring | GetFileNameW (const std::wstring &path) |
std::string | GetCurrentDirectoryA () |
Get the current directory. More... | |
std::wstring | GetCurrentDirectoryW () |
bool | FileExists (const std::string &filename) |
Check whether a file exists. More... | |
bool | FileExists (const std::wstring &filename) |
void | FileDelete (const std::string &filename) |
Delete a file. More... | |
void | FileDelete (const std::wstring &filename) |
void | FileCopy (const std::string &src, const std::string &dest, bool overwrite=true) |
Copy a file. More... | |
void | FileCopy (const std::wstring &src, const std::wstring &dest, bool overwrite=true) |
bool | DirectoryExists (const std::string &path) |
Check whether a directory exists. More... | |
bool | DirectoryExists (const std::wstring &path) |
std::string | DirectoryCreate (const std::string &path) |
Create a directory. More... | |
std::wstring | DirectoryCreate (const std::wstring &path) |
bool | DirectoryDelete (const std::string &path, int flags=DELETE_DIRECTORY_ALL) |
Delete a directory. More... | |
bool | DirectoryDelete (const std::wstring &path, int flags=DELETE_DIRECTORY_ALL) |
long | GetFileSize (const std::wstring &filename) |
Get file size. More... | |
long | GetFileSize (const std::string &filename) |
std::pair< std::string, std::string > | SizeToStringPairA (long size, FILESIZE_STRING_TYPE type=FILESIZE_AUTO, int precision=0) |
Convert a file size into a pair of strings. More... | |
std::pair< std::wstring, std::wstring > | SizeToStringPairW (long size, FILESIZE_STRING_TYPE type=FILESIZE_AUTO, int precision=0) |
std::string | SizeToStringA (long size, FILESIZE_STRING_TYPE type=FILESIZE_AUTO, int precision=0) |
Convert a file size into a string. More... | |
std::wstring | SizeToStringW (long size, FILESIZE_STRING_TYPE type=FILESIZE_AUTO, int precision=0) |
std::wstring | DirectoryCombine (const std::wstring &dir, const std::wstring &file) |
Combine two directory paths and an optional file. More... | |
std::list< std::wstring > | GetFiles (const std::wstring &path, const std::wstring &wildcard=L"*.*", int flags=GET_FILES_FILES) |
Get a list of files in a directory structure. More... | |
std::list< std::wstring > | GetFiles (const std::wstring &path_and_wildcard, int flags) |
Get a list of files in a directory structure. More... | |
std::list< std::wstring > | GetDirectoryFiles (const std::wstring &path, const std::wstring &wildcard=L"*.*") |
Get a list of file names in path. More... | |
void | ReadToEnd (const std::wstring &filename, std::wstring &data) |
Read the entire contents of file. More... | |
void | ReadToEnd (const std::wstring &filename, std::string &data) |
Read the entire contents of file. More... | |
void | ReadToEnd (const std::wstring &filename, std::vector< char > &data) |
Read the entire contents of file. More... | |
bool | ReadAndConvertToEnd (const std::wstring &filename, std::wstring &data) |
Read the entire contents of file and convert to UNICODE depending on the file marker. More... | |
void | FileWrite (const std::wstring &filename, const std::vector< char > &data, DWORD dwShareMode=GENERIC_READ|GENERIC_WRITE, DWORD dwCreationDisposition=CREATE_ALWAYS, DWORD dwFlagsAndAttributes=FILE_ATTRIBUTE_NORMAL) |
Write data to a file. More... | |
void | FileCreate (const std::wstring &filename, DWORD dwShareMode=GENERIC_READ|GENERIC_WRITE, DWORD dwCreationDisposition=CREATE_ALWAYS, DWORD dwFlagsAndAttributes=FILE_ATTRIBUTE_NORMAL) |
Create an empty file. More... | |
std::string | GetParentDirectory (const std::string &path) |
Get the parent directory of a path. More... | |
std::wstring | GetParentDirectory (const std::wstring &path) |
Get the parent directory of a path. More... | |
std::wstring | GetSpecialFolderPath (int csidl, BOOL create=FALSE) |
Takes the CSIDL of a folder and returns the path. More... | |
bool | IsAbsolutePath (const std::wstring &path) |
returns true if provided path is absolute, false otherwise More... | |
Variables | |
const long | BYTE = 1 |
const long | KBYTE = BYTE * 1024 |
const long | MBYTE = KBYTE * 1024 |
const long | GBYTE = MBYTE * 1024 |
Win32 File support functions.
std::wstring AppSecInc::File::DirectoryCombine | ( | const std::wstring & | dir, |
const std::wstring & | file | ||
) |
Combine two directory paths and an optional file.
std::string AppSecInc::File::DirectoryCreate | ( | const std::string & | path | ) |
Create a directory.
path | full path to the directory to create |
Create a directory with any subdirectories missing. This function will create subdirectories and will return the first directory actually created.
std::wstring AppSecInc::File::DirectoryCreate | ( | const std::wstring & | path | ) |
bool AppSecInc::File::DirectoryDelete | ( | const std::string & | path, |
int | flags = DELETE_DIRECTORY_ALL |
||
) |
Delete a directory.
\param path full path to the directory to delete
flags | flags for directory deletion |
Delete directories with subdirectories. Optionally delete filesand subdirectories. If flags is DELETE_DIRECTORY_FOLDERS deletes empty (sub)directories only. If an error occurs, the process aborts with an exception.
No error is thrown if the directory doesn't exist or if it contains no files or subdirectories.
bool AppSecInc::File::DirectoryDelete | ( | const std::wstring & | path, |
int | flags = DELETE_DIRECTORY_ALL |
||
) |
bool AppSecInc::File::DirectoryExists | ( | const std::string & | path | ) |
Check whether a directory exists.
Unlike Win32 ::PathFileExists this function fails when the parameter is not a directory (eg. a file) or on other errors (eg. access denied).
path | full path of the directory to check |
bool AppSecInc::File::DirectoryExists | ( | const std::wstring & | path | ) |
void AppSecInc::File::FileCopy | ( | const std::string & | src, |
const std::string & | dest, | ||
bool | overwrite = true |
||
) |
Copy a file.
src | source file |
dest | destination file |
void AppSecInc::File::FileCopy | ( | const std::wstring & | src, |
const std::wstring & | dest, | ||
bool | overwrite = true |
||
) |
void AppSecInc::File::FileCreate | ( | const std::wstring & | filename, |
DWORD | dwShareMode = GENERIC_READ | GENERIC_WRITE , |
||
DWORD | dwCreationDisposition = CREATE_ALWAYS , |
||
DWORD | dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL |
||
) |
Create an empty file.
dwShareMode | share mode |
dwCreationDisposition | creation disposition |
dwFlagsAndAttributes | flags and attributes |
void AppSecInc::File::FileDelete | ( | const std::string & | filename | ) |
Delete a file.
filename | full path of the file to delete |
void AppSecInc::File::FileDelete | ( | const std::wstring & | filename | ) |
bool AppSecInc::File::FileExists | ( | const std::string & | filename | ) |
Check whether a file exists.
Unlike Win32 ::PathFileExists this function fails when the parameter is not a file (eg. a directory) or on other errors (eg. access denied).
filename | full path of the file to check |
bool AppSecInc::File::FileExists | ( | const std::wstring & | filename | ) |
void AppSecInc::File::FileWrite | ( | const std::wstring & | filename, |
const std::vector< char > & | data, | ||
DWORD | dwShareMode = GENERIC_READ | GENERIC_WRITE , |
||
DWORD | dwCreationDisposition = CREATE_ALWAYS , |
||
DWORD | dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL |
||
) |
Write data to a file.
data | data to write |
dwShareMode | share mode |
dwCreationDisposition | creation disposition |
dwFlagsAndAttributes | flags and attributes |
std::string AppSecInc::File::GetCurrentDirectoryA | ( | ) |
Get the current directory.
std::wstring AppSecInc::File::GetCurrentDirectoryW | ( | ) |
std::list< std::wstring > AppSecInc::File::GetDirectoryFiles | ( | const std::wstring & | path, |
const std::wstring & | wildcard = L"*.*" |
||
) |
Get a list of file names in path.
path | full path |
wildcard | of files to find |
std::string AppSecInc::File::GetFileDirectoryA | ( | const std::string & | path | ) |
Get the directory portion of a full path.
path | input path |
std::wstring AppSecInc::File::GetFileDirectoryW | ( | const std::wstring & | path | ) |
std::string AppSecInc::File::GetFileNameA | ( | const std::string & | path | ) |
Get the filename portion of a full path.
path | input path |
std::wstring AppSecInc::File::GetFileNameW | ( | const std::wstring & | path | ) |
std::list< std::wstring > AppSecInc::File::GetFiles | ( | const std::wstring & | path, |
const std::wstring & | wildcard = L"*.*" , |
||
int | flags = GET_FILES_FILES |
||
) |
Get a list of files in a directory structure.
path | path at which to start looking |
flags | combination of GET_FILES_FLAGS |
std::list< std::wstring > AppSecInc::File::GetFiles | ( | const std::wstring & | path_and_wildcard, |
int | flags | ||
) |
Get a list of files in a directory structure.
path_and_wildcard | a combination of path and wildcard at which to start looking |
flags | combination of GET_FILES_FLAGS |
long AppSecInc::File::GetFileSize | ( | const std::wstring & | filename | ) |
Get file size.
long AppSecInc::File::GetFileSize | ( | const std::string & | filename | ) |
std::string AppSecInc::File::GetModuleDirectoryA | ( | ) |
Get the full path (directory) of the module's filename.
std::wstring AppSecInc::File::GetModuleDirectoryW | ( | ) |
std::string AppSecInc::File::GetModuleFileNameA | ( | HINSTANCE | h = NULL | ) |
Get the full path to the module's filename.
std::wstring AppSecInc::File::GetModuleFileNameW | ( | HINSTANCE | h = NULL | ) |
std::string AppSecInc::File::GetParentDirectory | ( | const std::string & | path | ) |
Get the parent directory of a path.
path | existing directory |
std::wstring AppSecInc::File::GetParentDirectory | ( | const std::wstring & | path | ) |
Get the parent directory of a path.
path | existing directory |
std::wstring AppSecInc::File::GetSpecialFolderPath | ( | int | csidl, |
BOOL | create = FALSE |
||
) |
Takes the CSIDL of a folder and returns the path.
csidl | a CSIDL value that identifies the folder whose path is to be retrieved |
create | Indicates whether the folder should be created if it does not already exist. |
std::string AppSecInc::File::GetTemporaryDirectoryA | ( | ) |
Get the location of the temporary directory.
std::wstring AppSecInc::File::GetTemporaryDirectoryW | ( | ) |
std::string AppSecInc::File::GetTemporaryFileNameA | ( | ) |
Create a temporary file and return its name.
std::wstring AppSecInc::File::GetTemporaryFileNameW | ( | ) |
bool AppSecInc::File::IsAbsolutePath | ( | const std::wstring & | path | ) |
returns true if provided path is absolute, false otherwise
bool AppSecInc::File::ReadAndConvertToEnd | ( | const std::wstring & | filename, |
std::wstring & | data | ||
) |
Read the entire contents of file and convert to UNICODE depending on the file marker.
filename | path to a file output, full contents of file in UNICODE format |
void AppSecInc::File::ReadToEnd | ( | const std::wstring & | filename, |
std::wstring & | data | ||
) |
Read the entire contents of file.
filename | path to a file with non-UNICODE contents |
void AppSecInc::File::ReadToEnd | ( | const std::wstring & | filename, |
std::string & | data | ||
) |
Read the entire contents of file.
filename | path to a file |
void AppSecInc::File::ReadToEnd | ( | const std::wstring & | filename, |
std::vector< char > & | data | ||
) |
Read the entire contents of file.
filename | path to a file |
std::string AppSecInc::File::SizeToStringA | ( | long | size, |
FILESIZE_STRING_TYPE | type = FILESIZE_AUTO , |
||
int | precision = 0 |
||
) |
Convert a file size into a string.
size | size to convert |
type | type of conversion |
precision | decimal precision |
std::pair< std::string, std::string > AppSecInc::File::SizeToStringPairA | ( | long | size, |
FILESIZE_STRING_TYPE | type = FILESIZE_AUTO , |
||
int | precision = 0 |
||
) |
Convert a file size into a pair of strings.
size | size to convert |
type | type of conversion |
precision | decimal precision |
std::pair< std::wstring, std::wstring > AppSecInc::File::SizeToStringPairW | ( | long | size, |
FILESIZE_STRING_TYPE | type = FILESIZE_AUTO , |
||
int | precision = 0 |
||
) |
std::wstring AppSecInc::File::SizeToStringW | ( | long | size, |
FILESIZE_STRING_TYPE | type = FILESIZE_AUTO , |
||
int | precision = 0 |
||
) |
const long AppSecInc::File::BYTE = 1 |
const long AppSecInc::File::GBYTE = MBYTE * 1024 |
const long AppSecInc::File::KBYTE = BYTE * 1024 |
const long AppSecInc::File::MBYTE = KBYTE * 1024 |
© Application Security Inc. - All Rights Reserved | http://msiext.codeplex.com |