20#undef GetModuleFileName
38bool chmod (
const char* filename,
int mode);
39bool chmod (
const std::string& filename,
int mode);
41bool access (
const char* filename,
int mode);
42bool access (
const std::string& filename,
int mode);
44bool splitpath (
const std::string& path,
char* drive,
char* dir,
char* fname,
char* ext);
45bool splitpath (
const std::string& path, std::string& drive, std::string& dir,
46 std::string& fname, std::string& ext);
47bool makepath (std::string& path,
const std::string& drive,
const std::string& dir,
48 const std::string& fname,
const std::string& ext);
49std::string
fullpath (
const std::string& relpath);
51std::string
getenv (
const std::string& var);
52bool putenv (
const std::string& str);
53bool putenv (
const std::string& var,
const std::string& val);
55bool symlink (
const char* path,
const char* link,
bool directory);
56bool symlink (
const std::string& path,
const std::string& target,
bool directory);
58int system (
const std::string& cmd);
60int MessageBox (HWND hWnd,
const std::string& text,
const std::string& caption,
62bool CopyFile (
const std::string& from,
const std::string& to,
bool fail_exist);
63std::string
LoadString (UINT
id, HINSTANCE hInst = NULL);
66LSTATUS
RegCreateKey (HKEY key,
const std::string& subkey, HKEY& result,
67 DWORD options = REG_OPTION_NON_VOLATILE, REGSAM sam = KEY_ALL_ACCESS,
68 const SECURITY_ATTRIBUTES* psa =
nullptr, DWORD* disp =
nullptr);
69LSTATUS
RegOpenKey (HKEY key,
const std::string& subkey, HKEY& result,
70 REGSAM sam = KEY_ALL_ACCESS,
bool link =
false);
71LSTATUS
RegDeleteKey (HKEY key,
const std::string& subkey, REGSAM sam = 0);
73LSTATUS
RegDeleteTree (HKEY key,
const std::string& subkey = std::string ());
74LSTATUS
RegRenameKey (HKEY key,
const std::string& subkey,
const std::string& new_name);
75LSTATUS
RegSetValue (HKEY key,
const std::string& value, DWORD type,
const void* data, DWORD size);
76LSTATUS
RegSetValue (HKEY key,
const std::string& value,
const std::string& data);
77LSTATUS
RegSetValue (HKEY key,
const std::string& value,
const std::vector<std::string>& data);
78LSTATUS
RegQueryValue (HKEY key,
const std::string& value, DWORD* type,
void* data, DWORD* size);
79LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
80 DWORD flags,
void* data, DWORD* size, DWORD* type = NULL);
81LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
82 std::string& data,
bool expand =
false);
83LSTATUS
RegGetValue (HKEY key,
const std::string& subkey,
const std::string& value,
84 std::vector<std::string>& data);
85LSTATUS
RegEnumKey (HKEY key, DWORD index, std::string& name, DWORD maxlen = 0, FILETIME* last_write_time = NULL);
86LSTATUS
RegEnumKey (HKEY key, std::vector<std::string>& names);
87LSTATUS
RegEnumValue (HKEY key, DWORD index, std::string& value, DWORD maxlen = 0, DWORD* type = 0,
void* data = 0, DWORD* data_len = 0);
88LSTATUS
RegEnumValue (HKEY key, std::vector<std::string>& values);
90HINSTANCE
ShellExecute (
const std::string& file,
const std::string& verb = std::string (),
91 const std::string& parameters = std::string (),
92 const std::string& directory = std::string (
"."),
93 HWND hWnd = NULL,
int show = SW_SHOW);
95std::string
GetTempFileName (
const std::string& path,
const std::string& prefix, UINT unique=0);
103 :
handle{ INVALID_HANDLE_VALUE }
148 operator bool ()
const;
162 explicit buffer (
size_t size_);
167 operator wchar_t* ();
168 operator std::string ()
const;
177operator << (std::ostream& s,
const buffer& b)
197bool chmod (
const char* filename,
int mode)
199 return (_wchmod (
widen (filename).c_str (), mode) == 0);
204bool chmod (
const std::string& filename,
int mode)
206 return (_wchmod (
widen (filename).c_str (), mode) == 0);
224bool access (
const char* filename,
int mode)
226 return (_waccess (
widen (filename).c_str (), mode) == 0);
231bool access (
const std::string& filename,
int mode)
233 return (_waccess (
widen (filename).c_str (), mode) == 0);
248 return (_wputenv (
utf8::widen (str).c_str ()) == 0);
262bool putenv (
const std::string& var,
const std::string& val)
264 return (_wputenv_s (
widen (var).c_str (),
265 widen (val).c_str ()) == 0);
280 return _wsystem (wcmd.c_str ());
296 if (
handle != INVALID_HANDLE_VALUE)
304 return (
handle != INVALID_HANDLE_VALUE);
310file_enumerator::operator bool ()
const
326 buffer::operator
wchar_t* ()
333 buffer::operator std::string ()
const
A simple buffer for caching values returned by Windows API.
Definition winutf8.h:160
buffer & operator=(const buffer &rhs)
Principal assignment operator.
Definition buffer.cpp:71
DWORD size() const
Return buffer size.
Definition winutf8.h:340
~buffer()
Destructor.
Definition buffer.cpp:55
An object - oriented wrapper for find_... functions.
Definition winutf8.h:141
file_enumerator(const std::string &name)
Constructs a file_enumerator object and tries to locate the first file.
Definition winutf8.h:287
bool next()
Advance the enumerator to next file.
Definition winutf8.h:317
bool ok() const
Return true if a file has been enumerated.
Definition winutf8.h:302
~file_enumerator()
Closes the search handle associated with this object.
Definition winutf8.h:294
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:101
__int64 size
file size
Definition winutf8.h:115
std::string filename
file name
Definition winutf8.h:116
DWORD attributes
file attributes
Definition winutf8.h:111
HANDLE handle
search handle
Definition winutf8.h:110
FILETIME access_time
file last access time
Definition winutf8.h:113
std::string short_name
8.3 file name
Definition winutf8.h:117
FILETIME creation_time
file creation time
Definition winutf8.h:112
FILETIME write_time
file last write time
Definition winutf8.h:114
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:246
bool chmod(const char *filename, int mode)
Changes the file access permissions.
Definition winutf8.h:197
int system(const std::string &cmd)
Passes command to command interpreter.
Definition winutf8.h:277
bool access(const char *filename, int mode)
Determines if a file has the requested access permissions.
Definition winutf8.h:224