UTF8 - Simple Library for Internationalization
|
Windows specific parts. More...
#include <Windows.h>
#include <string>
#include <ostream>
Go to the source code of this file.
Data Structures | |
struct | utf8::find_data |
File enumeration structure used by find_first() and find_next() functions. More... | |
class | utf8::file_enumerator |
An object - oriented wrapper for find_... functions. More... | |
class | utf8::buffer |
A simple buffer for caching values returned by Windows API. More... | |
Functions | |
std::vector< std::string > | utf8::get_argv () |
Converts wide byte command arguments to UTF-8 to a vector of UTF-8 strings. | |
char ** | utf8::get_argv (int *argc) |
Converts wide byte command arguments to an array of pointers to UTF-8 strings. | |
void | utf8::free_argv (int argc, char **argv) |
Frees the memory allocated by get_argv(int *argc) | |
bool | utf8::chmod (const char *filename, int mode) |
Changes the file access permissions. | |
bool | utf8::chmod (const std::string &filename, int mode) |
Changes the file access permissions. | |
bool | utf8::access (const char *filename, int mode) |
Determines if a file has the requested access permissions. | |
bool | utf8::access (const std::string &filename, int mode) |
Determines if a file has the requested access permissions. | |
bool | utf8::splitpath (const std::string &path, char *drive, char *dir, char *fname, char *ext) |
Breaks a path name into components. | |
bool | utf8::splitpath (const std::string &path, std::string &drive, std::string &dir, std::string &fname, std::string &ext) |
Breaks a path name into components. | |
bool | utf8::makepath (std::string &path, const std::string &drive, const std::string &dir, const std::string &fname, const std::string &ext) |
Creates a path from UTF-8 encoded components. | |
std::string | utf8::fullpath (const std::string &relpath) |
Returns the absolute (full) path of a filename. | |
std::string | utf8::getenv (const std::string &var) |
Retrieves the value of an environment variable. | |
bool | utf8::putenv (const std::string &str) |
Creates, modifies, or removes environment variables. | |
bool | utf8::putenv (const std::string &var, const std::string &val) |
Creates, modifies, or removes environment variables. | |
bool | utf8::symlink (const char *path, const char *link, bool directory) |
Create a symbolic link. | |
bool | utf8::symlink (const std::string &path, const std::string &link, bool directory) |
Create a symbolic link. | |
int | utf8::system (const std::string &cmd) |
Passes command to command interpreter. | |
int | utf8::MessageBox (HWND hWnd, const std::string &text, const std::string &caption, unsigned int type) |
Convenience wrapper for Windows MessageBox function. | |
bool | utf8::CopyFile (const std::string &from, const std::string &to, bool fail_exist) |
Convenience wrapper for Windows CopyFile function. | |
std::string | utf8::LoadString (UINT id, HINSTANCE hInst) |
Convenience wrapper for Windows LoadString function. | |
LSTATUS | utf8::RegCreateKey (HKEY key, const std::string &subkey, HKEY &result, DWORD options, REGSAM sam, const SECURITY_ATTRIBUTES *psa, DWORD *disp) |
Convenience wrapper for RegCreateKeyEx | |
LSTATUS | utf8::RegOpenKey (HKEY key, const std::string &subkey, HKEY &result, REGSAM sam, bool link) |
Wrapper for RegOpenKeyEx | |
LSTATUS | utf8::RegDeleteKey (HKEY key, const std::string &subkey, REGSAM sam) |
Wrapper for RegDeleteKeyEx or RegDeleteKey | |
LSTATUS | utf8::RegDeleteValue (HKEY key, const std::string &value) |
Wrapper for RegDeleteValue | |
LSTATUS | utf8::RegDeleteTree (HKEY key, const std::string &subkey) |
Wrapper for RegDeleteTree | |
LSTATUS | utf8::RegRenameKey (HKEY key, const std::string &subkey, const std::string &new_name) |
Wrapper for RegRenameKey | |
LSTATUS | utf8::RegSetValue (HKEY key, const std::string &value, DWORD type, const void *data, DWORD size) |
Wrapper for RegSetValueEx | |
LSTATUS | utf8::RegSetValue (HKEY key, const std::string &value, const std::string &data) |
Convenience Wrapper for RegSetValueEx for string data. | |
LSTATUS | utf8::RegSetValue (HKEY key, const std::string &value, const std::vector< std::string > &data) |
Convenience Wrapper for RegSetValueEx for vector of string data. | |
LSTATUS | utf8::RegQueryValue (HKEY key, const std::string &value, DWORD *type, void *data, DWORD *size) |
Wrapper for RegQueryValueEx | |
LSTATUS | utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, DWORD flags, void *data, DWORD *size, DWORD *type) |
Wrapper for RegGetValue | |
LSTATUS | utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, std::string &data, bool expand) |
Retrieves a string from a registry key value using the RegGetValue function. | |
LSTATUS | utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, std::vector< std::string > &data) |
Retrieves a vector of strings from a registry key value using the RegGetValue function. | |
LSTATUS | utf8::RegEnumKey (HKEY key, DWORD index, std::string &name, DWORD maxlen, FILETIME *last_write_time) |
Wrapper for RegEnumKeyEx | |
LSTATUS | utf8::RegEnumKey (HKEY key, std::vector< std::string > &names) |
Enumerate all subkeys of a key. | |
LSTATUS | utf8::RegEnumValue (HKEY key, DWORD index, std::string &value, DWORD maxlen, DWORD *type, void *data, DWORD *data_len) |
Wrapper for RegEnumValue | |
LSTATUS | utf8::RegEnumValue (HKEY key, std::vector< std::string > &values) |
Enumerate all values of a key. | |
HINSTANCE | utf8::ShellExecute (const std::string &file, const std::string &verb, const std::string ¶meters, const std::string &directory, HWND hWnd, int show) |
Convenience wrapper for Windows ShellExecute function. | |
std::string | utf8::GetTempPath () |
Convenience wrapper for GetTempPath | |
std::string | utf8::GetTempFileName (const std::string &path, const std::string &prefix, UINT unique) |
Convenience wrapper for GetTempFileName | |
std::string | utf8::GetFullPathName (const std::string &rel_path) |
Convenience wrapper for GetFullPathName | |
bool | utf8::GetModuleFileName (HMODULE hModule, std::string &filename) |
Convenience wrapper for GetModuleFileName | |
std::string | utf8::GetModuleFileName (HMODULE hModule) |
Convenience wrapper for GetModuleFileName | |
bool | utf8::find_first (const std::string &name, find_data &fdat) |
Searches a directory for a file or subdirectory with a name that matches a name (that can have wildcards). | |
bool | utf8::find_next (find_data &fdat) |
Continues a search started by find_first() function. | |
void | utf8::find_close (find_data &fdat) |
Closes a "search handle" opened by find_first() function. | |
std::ostream & | utf8::operator<< (std::ostream &s, const buffer &b) |
Windows specific parts.
|
inline |
Determines if a file has the requested access permissions.
filename | UTF-8 file path of new working directory |
mode | required access:
|
|
inline |
Determines if a file has the requested access permissions.
filename | UTF-8 file path of new working directory |
mode | required access:
|
|
inline |
Changes the file access permissions.
filename | UTF-8 name of file |
mode | access permissions. Or'ed combination of:
|
|
inline |
Changes the file access permissions.
filename | UTF-8 name of file |
mode | access permissions. Or'ed combination of:
|
bool utf8::CopyFile | ( | const std::string & | from, |
const std::string & | to, | ||
bool | fail_exist | ||
) |
Convenience wrapper for Windows CopyFile function.
from | Name of the existing file |
to | Name of the new file |
fail_exist |
bool utf8::find_first | ( | const std::string & | name, |
find_data & | fdat | ||
) |
Searches a directory for a file or subdirectory with a name that matches a name (that can have wildcards).
name | File name (or partial file name) to find |
fdat | Information structure containing file name and attributes |
If successful, the function opens a "search handle" stored in the fdat structure. The handle has to be closed using find_close() function.
bool utf8::find_next | ( | find_data & | fdat | ) |
Continues a search started by find_first() function.
fdat | search results structure containing file information |
If there are no more files, the function returns false and GetLastError function returns ERROR_NO_MORE_FILES
void utf8::free_argv | ( | int | argc, |
char ** | argv | ||
) |
Frees the memory allocated by get_argv(int *argc)
argc | number of arguments |
argv | array of pointers to arguments |
std::string utf8::fullpath | ( | const std::string & | relpath | ) |
Returns the absolute (full) path of a filename.
relpath | relative path |
std::vector< std::string > utf8::get_argv | ( | ) |
Converts wide byte command arguments to UTF-8 to a vector of UTF-8 strings.
char ** utf8::get_argv | ( | int * | argc | ) |
Converts wide byte command arguments to an array of pointers to UTF-8 strings.
argc | Pointer to an integer that contains number of parameters |
The space allocated for strings and array of pointers should be freed by calling free_utf8argv()
std::string utf8::getenv | ( | const std::string & | var | ) |
Retrieves the value of an environment variable.
var | name of environment variable |
std::string utf8::GetFullPathName | ( | const std::string & | rel_path | ) |
Convenience wrapper for GetFullPathName
rel_path | relative path name |
std::string utf8::GetModuleFileName | ( | HMODULE | hModule | ) |
Convenience wrapper for GetModuleFileName
hModule | module handle for which path will be retrieved or NULL to retrieve path of current executable. |
bool utf8::GetModuleFileName | ( | HMODULE | hModule, |
std::string & | filename | ||
) |
Convenience wrapper for GetModuleFileName
hModule | module handle for which path will be retrieved or NULL to retrieve path of current executable. |
filename | UTF-8 encoded module file name |
true
if successful false
otherwise std::string utf8::GetTempFileName | ( | const std::string & | path, |
const std::string & | prefix, | ||
UINT | unique | ||
) |
Convenience wrapper for GetTempFileName
path | directory path |
prefix | filename prefix (up to 3 characters) |
unique | integer value used to create filename |
<path>\<prefix>nnnnn.tmp
std::string utf8::GetTempPath | ( | ) |
Convenience wrapper for GetTempPath
std::string utf8::LoadString | ( | UINT | id, |
HINSTANCE | hInst | ||
) |
Convenience wrapper for Windows LoadString function.
id | String identifier |
hInst | module handle of the module containing the string resource |
bool utf8::makepath | ( | std::string & | path, |
const std::string & | drive, | ||
const std::string & | dir, | ||
const std::string & | fname, | ||
const std::string & | ext | ||
) |
Creates a path from UTF-8 encoded components.
path | Resulting path (UTF-8 encoded) |
drive | drive letter |
dir | directory path |
fname | filename |
ext | extension |
If any required syntactic element (colon after drive letter, '\' at end of directory path, colon before extension) is missing, it is automatically added.
int utf8::MessageBox | ( | HWND | hWnd, |
const std::string & | text, | ||
const std::string & | caption, | ||
unsigned int | type | ||
) |
Convenience wrapper for Windows MessageBox function.
hWnd | handle to the owner window |
text | UTF-8 encoded message to be displayed |
caption | UTF-8 encoded dialog box title |
type | flags for content and behavior of the dialog box |
|
inline |
Creates, modifies, or removes environment variables.
This is a wrapper for _wputenv function.
str | environment string to modify |
|
inline |
Creates, modifies, or removes environment variables.
This is a wrapper for _wputenv_s function.
var | name of environment variable |
val | new value of environment variable. If empty, the environment variable is removed |
HINSTANCE utf8::ShellExecute | ( | const std::string & | file, |
const std::string & | verb, | ||
const std::string & | parameters, | ||
const std::string & | directory, | ||
HWND | hWnd, | ||
int | show | ||
) |
Convenience wrapper for Windows ShellExecute function.
file | file or object on which to execute the specified verb |
verb | action to be performed |
parameters | parameters to be passed to the application |
directory | default (working) directory |
hWnd | handle to the parent window |
show | parameter for the ShowWindow function |
bool utf8::splitpath | ( | const std::string & | path, |
char * | drive, | ||
char * | dir, | ||
char * | fname, | ||
char * | ext | ||
) |
Breaks a path name into components.
path | UTF-8 encoded full path |
drive | drive letter followed by colon (or NULL if not needed) |
dir | directory path (or NULL if not needed) |
fname | base filename (or NULL if not needed) |
ext | file extension including the leading period (.) (or NULL if not needed) |
bool utf8::splitpath | ( | const std::string & | path, |
std::string & | drive, | ||
std::string & | dir, | ||
std::string & | fname, | ||
std::string & | ext | ||
) |
Breaks a path name into components.
path | UTF-8 encoded full path |
drive | drive letter followed by colon |
dir | directory path |
fname | base filename |
ext | file extension including the leading period (.) |
Returned strings are converted to UTF-8.
bool utf8::symlink | ( | const char * | path, |
const char * | link, | ||
bool | directory | ||
) |
Create a symbolic link.
path | target path name |
link | name of symbolic link |
directory | true if link target is a directory |
bool utf8::symlink | ( | const std::string & | path, |
const std::string & | link, | ||
bool | directory | ||
) |
Create a symbolic link.
path | target path name |
link | name of symbolic link |
directory | true if link target is a directory |
|
inline |
Passes command to command interpreter.
cmd | UTF-8 encoded command to pass |
This is a wrapper for _wsystem function.