mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-01 15:28:25 -04:00
[misc] add _mkdirExU and _rmdirU to msapi_utf8.h
This commit is contained in:
parent
4bf69215bf
commit
b3d35b27df
2 changed files with 43 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <setupapi.h>
|
||||
#include <direct.h>
|
||||
#include <share.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -1072,6 +1073,43 @@ static __inline int _mkdirU(const char* dirname)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// This version of _mkdirU creates all needed directories along the way
|
||||
static __inline int _mkdirExU(const char* dirname)
|
||||
{
|
||||
int ret = -1, trailing_slash = -1;
|
||||
size_t i, len;
|
||||
wconvert(dirname);
|
||||
len = wcslen(wdirname);
|
||||
while (trailing_slash && (len > 0)) {
|
||||
if ((wdirname[len - 1] == '\\') || (wdirname[len - 1] == '/'))
|
||||
wdirname[--len] = 0;
|
||||
else
|
||||
trailing_slash = 0;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
if ((wdirname[i] == '\\') || (wdirname[i] == '/'))
|
||||
wdirname[i] = 0;
|
||||
for (i = 0; i < len; ) {
|
||||
if ((_wmkdir(wdirname) < 0) && (errno != EEXIST) && (errno != EACCES))
|
||||
goto out;
|
||||
i = wcslen(wdirname);
|
||||
wdirname[i] = '\\';
|
||||
}
|
||||
ret = 0;
|
||||
out:
|
||||
wfree(dirname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline int _rmdirU(const char* dirname)
|
||||
{
|
||||
wconvert(dirname);
|
||||
int ret;
|
||||
ret = _wrmdir(wdirname);
|
||||
wfree(dirname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The following expects PropertyBuffer to contain a single Unicode string
|
||||
static __inline BOOL SetupDiGetDeviceRegistryPropertyU(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData,
|
||||
DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue