22#undef GetModuleFileName
40bool chmod (
const char* filename,
int mode);
41bool chmod (
const std::string& filename,
int mode);
43bool access (
const char* filename,
int mode);
44bool access (
const std::string& filename,
int mode);
46bool splitpath (
const std::string& path,
char* drive,
char* dir,
char* fname,
char* ext);
47bool splitpath (
const std::string& path, std::string& drive, std::string& dir,
48 std::string& fname, std::string& ext);
49bool makepath (std::string& path,
const std::string& drive,
const std::string& dir,
50 const std::string& fname,
const std::string& ext);
51std::string
fullpath (
const std::string& relpath);
53std::string
getenv (
const std::string& var);
54bool putenv (
const std::string& str);
55bool putenv (
const std::string& var,
const std::string& val);
57bool symlink (
const char* path,
const char* link,
bool directory);
58bool symlink (
const std::string& path,
const std::string& target,
bool directory);
60int system (
const std::string& cmd);
62int MessageBox (HWND hWnd,
const std::string& text,
const std::string& caption,
64bool CopyFile (
const std::string& from,
const std::string& to,
bool fail_exist);
65std::string
LoadString (UINT
id, HINSTANCE hInst = NULL);
68LSTATUS
RegCreateKey (HKEY key,
const std::string& subkey, HKEY& result,
69 DWORD options = REG_OPTION_NON_VOLATILE, REGSAM sam = KEY_ALL_ACCESS,
70 const SECURITY_ATTRIBUTES* psa =
nullptr, DWORD* disp =
nullptr);
71LSTATUS
RegOpenKey (HKEY key,
const std::string& subkey, HKEY& result,
72 REGSAM sam = KEY_ALL_ACCESS,
bool link =
false);
73LSTATUS
RegDeleteKey (HKEY key,
const std::string& subkey, REGSAM sam = 0);
75LSTATUS
RegDeleteTree (HKEY key,
const std::string& subkey = std::string ());
76LSTATUS
RegRenameKey (HKEY key,
const std::string& subkey,
const std::string& new_name);
77LSTATUS
RegSetValue (HKEY key,
const std::string& value, DWORD type,
const void* data, DWORD size);
78LSTATUS
RegSetValue (HKEY key,
const std::string& value,
const std::string& data);
79LSTATUS
RegSetValue (HKEY key,
const std::string& value,
const std::vector<std::string>& data);
80LSTATUS
RegQueryValue (HKEY key,
const std::string& value, DWORD* type,
void* data, DWORD* size);
81LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
82 DWORD flags,
void* data, DWORD* size, DWORD* type = NULL);
83LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
84 std::string& data,
bool expand =
false);
85LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
86 std::vector<std::string>& data);
87LSTATUS
RegEnumKey (HKEY key, DWORD index, std::string& name, DWORD maxlen = 0, FILETIME* last_write_time = NULL);
88LSTATUS
RegEnumKey (HKEY key, std::vector<std::string>& names);
89LSTATUS
RegEnumValue (HKEY key, DWORD index, std::string& value, DWORD maxlen = 0, DWORD* type = 0,
void* data = 0, DWORD* data_len = 0);
90LSTATUS
RegEnumValue (HKEY key, std::vector<std::string>& values);
92HINSTANCE
ShellExecute (
const std::string& file,
const std::string& verb = std::string (),
93 const std::string& parameters = std::string (),
94 const std::string& directory = std::string (
"."),
95 HWND hWnd = NULL,
int show = SW_SHOW);
97std::string
GetTempFileName (
const std::string& path,
const std::string& prefix, UINT unique=0);
105 :
handle{ INVALID_HANDLE_VALUE }
150 operator bool ()
const;
164 explicit buffer (
size_t size_);
169 operator wchar_t* ();
170 operator std::string ()
const;
179operator << (std::ostream& s,
const buffer& b)
199bool chmod (
const char* filename,
int mode)
201 return (_wchmod (
widen (filename).c_str (), mode) == 0);
206bool chmod (
const std::string& filename,
int mode)
208 return (_wchmod (
widen (filename).c_str (), mode) == 0);
226bool access (
const char* filename,
int mode)
228 return (_waccess (
widen (filename).c_str (), mode) == 0);
233bool access (
const std::string& filename,
int mode)
235 return (_waccess (
widen (filename).c_str (), mode) == 0);
250 return (_wputenv (
utf8::widen (str).c_str ()) == 0);
264bool putenv (
const std::string& var,
const std::string& val)
266 return (_wputenv_s (
widen (var).c_str (),
267 widen (val).c_str ()) == 0);
282 return _wsystem (wcmd.c_str ());
298 if (
handle != INVALID_HANDLE_VALUE)
306 return (
handle != INVALID_HANDLE_VALUE);
312file_enumerator::operator bool ()
const
328 buffer::operator
wchar_t* ()
335 buffer::operator std::string ()
const
A simple buffer for caching values returned by Windows API.
Definition winutf8.h:162
buffer & operator=(const buffer &rhs)
Principal assignment operator.
Definition buffer.cpp:71
DWORD size() const
Return buffer size.
Definition winutf8.h:342
~buffer()
Destructor.
Definition buffer.cpp:55
An object - oriented wrapper for find_... functions.
Definition winutf8.h:143
file_enumerator(const std::string &name)
Constructs a file_enumerator object and tries to locate the first file.
Definition winutf8.h:289
bool next()
Advance the enumerator to next file.
Definition winutf8.h:319
bool ok() const
Return true if a file has been enumerated.
Definition winutf8.h:304
~file_enumerator()
Closes the search handle associated with this object.
Definition winutf8.h:296
std::string narrow(const wchar_t *s, size_t nch)
Conversion from wide character to UTF-8.
Definition utf8.cpp:52
std::wstring widen(const char *s, size_t nch)
Conversion from UTF-8 to wide character.
Definition utf8.cpp:207
LSTATUS RegCreateKey(HKEY key, const std::string &subkey, HKEY &result, DWORD options, REGSAM sam, const SECURITY_ATTRIBUTES *psa, DWORD *disp)
Convenience wrapper for RegCreateKeyEx
Definition win.cpp:483
LSTATUS RegGetValue(HKEY key, const std::string &subkey, const std::string &value, DWORD flags, void *data, DWORD *size, DWORD *type)
Wrapper for RegGetValue
Definition win.cpp:683
LSTATUS RegDeleteKey(HKEY key, const std::string &subkey, REGSAM sam)
Wrapper for RegDeleteKeyEx or RegDeleteKey
Definition win.cpp:522
LSTATUS RegSetValue(HKEY key, const std::string &value, DWORD type, const void *data, DWORD size)
Wrapper for RegSetValueEx
Definition win.cpp:590
LSTATUS RegDeleteTree(HKEY key, const std::string &subkey)
Wrapper for RegDeleteTree
Definition win.cpp:555
LSTATUS RegRenameKey(HKEY key, const std::string &subkey, const std::string &new_name)
Wrapper for RegRenameKey
Definition win.cpp:572
LSTATUS RegQueryValue(HKEY key, const std::string &value, DWORD *type, void *data, DWORD *size)
Wrapper for RegQueryValueEx
Definition win.cpp:664
LSTATUS RegEnumKey(HKEY key, DWORD index, std::string &name, DWORD maxlen, FILETIME *last_write_time)
Wrapper for RegEnumKeyEx
Definition win.cpp:779
LSTATUS RegDeleteValue(HKEY key, const std::string &value)
Wrapper for RegDeleteValue
Definition win.cpp:540
LSTATUS RegOpenKey(HKEY key, const std::string &subkey, HKEY &result, REGSAM sam, bool link)
Wrapper for RegOpenKeyEx
Definition win.cpp:499
LSTATUS RegEnumValue(HKEY key, DWORD index, std::string &value, DWORD maxlen, DWORD *type, void *data, DWORD *data_len)
Wrapper for RegEnumValue
Definition win.cpp:847
File enumeration structure used by find_first() and find_next() functions.
Definition winutf8.h:103
std::string filename
file name
Definition winutf8.h:118
DWORD attributes
file attributes
Definition winutf8.h:113
HANDLE handle
search handle
Definition winutf8.h:112
FILETIME access_time
file last access time
Definition winutf8.h:115
int64_t size
file size
Definition winutf8.h:117
std::string short_name
8.3 file name
Definition winutf8.h:119
FILETIME creation_time
file creation time
Definition winutf8.h:114
FILETIME write_time
file last write time
Definition winutf8.h:116
UTF-8 Conversion functions.
std::string GetTempPath()
Convenience wrapper for GetTempPath
Definition win.cpp:171
bool 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.
Definition win.cpp:353
bool 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 wildca...
Definition win.cpp:40
std::string fullpath(const std::string &relpath)
Returns the absolute (full) path of a filename.
Definition win.cpp:368
bool GetModuleFileName(HMODULE hModule, std::string &filename)
Convenience wrapper for GetModuleFileName
Definition win.cpp:227
std::string LoadString(UINT id, HINSTANCE hInst)
Convenience wrapper for Windows LoadString function.
Definition win.cpp:134
HINSTANCE 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.
Definition win.cpp:155
std::string getenv(const std::string &var)
Retrieves the value of an environment variable.
Definition win.cpp:383
int MessageBox(HWND hWnd, const std::string &text, const std::string &caption, unsigned int type)
Convenience wrapper for Windows MessageBox function.
Definition win.cpp:107
bool splitpath(const std::string &path, char *drive, char *dir, char *fname, char *ext)
Breaks a path name into components.
Definition win.cpp:289
void free_argv(int argc, char **argv)
Frees the memory allocated by get_argv(int *argc)
Definition win.cpp:432
bool find_next(find_data &fdat)
Continues a search started by find_first() function.
Definition win.cpp:64
bool CopyFile(const std::string &from, const std::string &to, bool fail_exist)
Convenience wrapper for Windows CopyFile function.
Definition win.cpp:121
std::string GetFullPathName(const std::string &rel_path)
Convenience wrapper for GetFullPathName
Definition win.cpp:205
char ** get_argv(int *argc)
Converts wide byte command arguments to an array of pointers to UTF-8 strings.
Definition win.cpp:408
std::string GetTempFileName(const std::string &path, const std::string &prefix, UINT unique)
Convenience wrapper for GetTempFileName
Definition win.cpp:188
bool symlink(const char *path, const char *link, bool directory)
Create a symbolic link.
Definition win.cpp:264
void find_close(find_data &fdat)
Closes a "search handle" opened by find_first() function.
Definition win.cpp:88
bool putenv(const std::string &str)
Creates, modifies, or removes environment variables.
Definition winutf8.h:248
bool chmod(const char *filename, int mode)
Changes the file access permissions.
Definition winutf8.h:199
int system(const std::string &cmd)
Passes command to command interpreter.
Definition winutf8.h:279
bool access(const char *filename, int mode)
Determines if a file has the requested access permissions.
Definition winutf8.h:226