friend with UNICODE macro on windows
This commit is contained in:
@@ -772,7 +772,7 @@ bool PITerminal::initialize() {
|
|||||||
destroy();
|
destroy();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PRIVATE->pipe = CreateNamedPipe((LPSTR)pname.dataAscii(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 2, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 1000, NULL);
|
PRIVATE->pipe = CreateNamedPipeA((LPSTR)pname.dataAscii(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 2, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 1000, NULL);
|
||||||
if (PRIVATE->pipe == INVALID_HANDLE_VALUE) {
|
if (PRIVATE->pipe == INVALID_HANDLE_VALUE) {
|
||||||
piCoutObj << "CreateNamedPipe error," << errorString();
|
piCoutObj << "CreateNamedPipe error," << errorString();
|
||||||
destroy();
|
destroy();
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ PIInit::PIInit() {
|
|||||||
if (__pi_perf_freq == 0) __pi_perf_freq = -1;
|
if (__pi_perf_freq == 0) __pi_perf_freq = -1;
|
||||||
|
|
||||||
// Sleep precision init
|
// Sleep precision init
|
||||||
PRIVATE->ntlib = LoadLibrary("ntdll.dll");
|
PRIVATE->ntlib = LoadLibraryA("ntdll.dll");
|
||||||
if (PRIVATE->ntlib) {
|
if (PRIVATE->ntlib) {
|
||||||
getTimerResolutionAddr = (PINtQueryTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtQueryTimerResolution");
|
getTimerResolutionAddr = (PINtQueryTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtQueryTimerResolution");
|
||||||
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
||||||
@@ -221,7 +221,7 @@ PIInit::PIInit() {
|
|||||||
LocalFree(argv_);
|
LocalFree(argv_);
|
||||||
memset(cbuff, 0, 1024);
|
memset(cbuff, 0, 1024);
|
||||||
ulong unlen = 1023;
|
ulong unlen = 1023;
|
||||||
if (GetUserName(cbuff, &unlen) != 0)
|
if (GetUserNameA(cbuff, &unlen) != 0)
|
||||||
sinfo->user = cbuff;
|
sinfo->user = cbuff;
|
||||||
#else //WINDOWS
|
#else //WINDOWS
|
||||||
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
|
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
if (dp == separator) {
|
if (dp == separator) {
|
||||||
char letters[1024];
|
char letters[1024];
|
||||||
PIFile::FileInfo fi;
|
PIFile::FileInfo fi;
|
||||||
DWORD ll = GetLogicalDriveStrings(1023, letters);
|
DWORD ll = GetLogicalDriveStringsA(1023, letters);
|
||||||
PIString clet;
|
PIString clet;
|
||||||
for (DWORD i = 0; i < ll; ++i) {
|
for (DWORD i = 0; i < ll; ++i) {
|
||||||
if (letters[i] == '\0') {
|
if (letters[i] == '\0') {
|
||||||
@@ -298,9 +298,9 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
clet += PIChar(letters[i]);
|
clet += PIChar(letters[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WIN32_FIND_DATA fd; memset(&fd, 0, sizeof(fd));
|
WIN32_FIND_DATAA fd; memset(&fd, 0, sizeof(fd));
|
||||||
p += "\\*";
|
p += "\\*";
|
||||||
void * hf = FindFirstFile((LPCTSTR)(p.data()), &fd);
|
void * hf = FindFirstFileA((LPCSTR)(p.data()), &fd);
|
||||||
if (!hf) return l;
|
if (!hf) return l;
|
||||||
bool hdd = false;
|
bool hdd = false;
|
||||||
do {
|
do {
|
||||||
@@ -308,7 +308,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
|
|||||||
if (fn == "..") hdd = true;
|
if (fn == "..") hdd = true;
|
||||||
l << PIFile::fileInfo(dp + fn);
|
l << PIFile::fileInfo(dp + fn);
|
||||||
memset(&fd, 0, sizeof(fd));
|
memset(&fd, 0, sizeof(fd));
|
||||||
} while (FindNextFile(hf, &fd) != 0);
|
} while (FindNextFileA(hf, &fd) != 0);
|
||||||
FindClose(hf);
|
FindClose(hf);
|
||||||
l.sort(sort_compare);
|
l.sort(sort_compare);
|
||||||
if (!hdd) {
|
if (!hdd) {
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ bool PIFile::isExists(const PIString & path) {
|
|||||||
bool PIFile::remove(const PIString & path) {
|
bool PIFile::remove(const PIString & path) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
if (PIDir::isExists(path))
|
if (PIDir::isExists(path))
|
||||||
return RemoveDirectory(path.data()) > 0;
|
return RemoveDirectoryA(path.data()) > 0;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
return ::remove(path.data()) == 0;
|
return ::remove(path.data()) == 0;
|
||||||
@@ -475,13 +475,13 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
PIString n = ret.name();
|
PIString n = ret.name();
|
||||||
//piCout << "open" << path;
|
//piCout << "open" << path;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
DWORD attr = GetFileAttributes((LPCTSTR)(path.data()));
|
DWORD attr = GetFileAttributesA((LPCSTR)(path.data()));
|
||||||
if (attr == 0xFFFFFFFF) return ret;
|
if (attr == 0xFFFFFFFF) return ret;
|
||||||
HANDLE hFile = 0;
|
HANDLE hFile = 0;
|
||||||
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
hFile = CreateFile(path.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
hFile = CreateFileA(path.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||||
} else {
|
} else {
|
||||||
hFile = CreateFile(path.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
hFile = CreateFileA(path.data(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||||
}
|
}
|
||||||
if (!hFile) return ret;
|
if (!hFile) return ret;
|
||||||
BY_HANDLE_FILE_INFORMATION fi;
|
BY_HANDLE_FILE_INFORMATION fi;
|
||||||
@@ -557,19 +557,19 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
|
|||||||
PIString fp(path);
|
PIString fp(path);
|
||||||
if (fp.endsWith(PIDir::separator)) fp.pop_back();
|
if (fp.endsWith(PIDir::separator)) fp.pop_back();
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
DWORD attr = GetFileAttributes((LPCTSTR)(path.data()));
|
DWORD attr = GetFileAttributesA((LPCSTR)(path.data()));
|
||||||
if (attr == 0xFFFFFFFF) return false;
|
if (attr == 0xFFFFFFFF) return false;
|
||||||
attr &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY);
|
attr &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY);
|
||||||
if (info.isHidden()) attr |= FILE_ATTRIBUTE_HIDDEN;
|
if (info.isHidden()) attr |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
if (!info.perm_user.write) attr |= FILE_ATTRIBUTE_READONLY;
|
if (!info.perm_user.write) attr |= FILE_ATTRIBUTE_READONLY;
|
||||||
if (SetFileAttributes((LPCTSTR)(fp.data()), attr) == 0) {
|
if (SetFileAttributesA((LPCSTR)(fp.data()), attr) == 0) {
|
||||||
piCout << "[PIFile] applyFileInfo: \"SetFileAttributes\" error:" << errorString();
|
piCout << "[PIFile] applyFileInfo: \"SetFileAttributes\" error:" << errorString();
|
||||||
}
|
}
|
||||||
HANDLE hFile = 0;
|
HANDLE hFile = 0;
|
||||||
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
hFile = CreateFile(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
hFile = CreateFileA(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||||
} else {
|
} else {
|
||||||
hFile = CreateFile(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
hFile = CreateFileA(path.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||||
}
|
}
|
||||||
if (!hFile) return false;
|
if (!hFile) return false;
|
||||||
FILETIME atime = PIDateTime2FILETIME(info.time_access), mtime = PIDateTime2FILETIME(info.time_modification);
|
FILETIME atime = PIDateTime2FILETIME(info.time_access), mtime = PIDateTime2FILETIME(info.time_modification);
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ bool PISharedMemory::openDevice() {
|
|||||||
PRIVATE->name = ("PIP_SHM_" + path()).toByteArray();
|
PRIVATE->name = ("PIP_SHM_" + path()).toByteArray();
|
||||||
PRIVATE->name.push_back(0);
|
PRIVATE->name.push_back(0);
|
||||||
const char * nm = (const char *)PRIVATE->name.data();
|
const char * nm = (const char *)PRIVATE->name.data();
|
||||||
PRIVATE->map = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, nm);
|
PRIVATE->map = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, nm);
|
||||||
//piCoutObj << "open map =" << ullong(PRIVATE->map);
|
//piCoutObj << "open map =" << ullong(PRIVATE->map);
|
||||||
if (!PRIVATE->map) {
|
if (!PRIVATE->map) {
|
||||||
PRIVATE->map = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)dsize, nm);
|
PRIVATE->map = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)dsize, nm);
|
||||||
//piCoutObj << "create map =" << ullong(PRIVATE->map);
|
//piCoutObj << "create map =" << ullong(PRIVATE->map);
|
||||||
if (!PRIVATE->map) {
|
if (!PRIVATE->map) {
|
||||||
piCoutObj << "CreateFileMapping error," << errorString();
|
piCoutObj << "CreateFileMapping error," << errorString();
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ bool PILibrary::loadInternal() {
|
|||||||
unload();
|
unload();
|
||||||
if (libpath.isEmpty()) return false;
|
if (libpath.isEmpty()) return false;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
PRIVATE->hLib = LoadLibrary(libpath.data());
|
PRIVATE->hLib = LoadLibraryA(libpath.data());
|
||||||
#else
|
#else
|
||||||
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
|
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ PIStringList PISystemInfo::mountRoots() {
|
|||||||
PIStringList ret;
|
PIStringList ret;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char letters[1024];
|
char letters[1024];
|
||||||
DWORD ll = GetLogicalDriveStrings(1023, letters);
|
DWORD ll = GetLogicalDriveStringsA(1023, letters);
|
||||||
PIString clet;
|
PIString clet;
|
||||||
for (uint i = 0; i < ll; ++i) {
|
for (uint i = 0; i < ll; ++i) {
|
||||||
if (letters[i] == '\0') {
|
if (letters[i] == '\0') {
|
||||||
@@ -93,26 +93,26 @@ PIVector<PISystemInfo::MountInfo> PISystemInfo::mountInfo(bool ignore_cache) {
|
|||||||
MountInfo m;
|
MountInfo m;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char letters[1024], volname[1024], volfs[1024];
|
char letters[1024], volname[1024], volfs[1024];
|
||||||
DWORD ll = GetLogicalDriveStrings(1023, letters);
|
DWORD ll = GetLogicalDriveStringsA(1023, letters);
|
||||||
PIString clet;
|
PIString clet;
|
||||||
for (DWORD i = 0; i < ll; ++i) {
|
for (DWORD i = 0; i < ll; ++i) {
|
||||||
if (letters[i] == '\0') {
|
if (letters[i] == '\0') {
|
||||||
if (GetVolumeInformation(clet.data(), volname, 1023, 0, 0, 0, volfs, 1023)) {
|
if (GetVolumeInformationA(clet.data(), volname, 1023, 0, 0, 0, volfs, 1023)) {
|
||||||
m.mount_point = clet;
|
m.mount_point = clet;
|
||||||
m.filesystem = volfs;
|
m.filesystem = volfs;
|
||||||
m.label = volname;
|
m.label = volname;
|
||||||
DWORD spc, bps, free_cl, all_cl;
|
DWORD spc, bps, free_cl, all_cl;
|
||||||
if (GetDiskFreeSpace(clet.data(), &spc, &bps, &free_cl, &all_cl)) {
|
if (GetDiskFreeSpaceA(clet.data(), &spc, &bps, &free_cl, &all_cl)) {
|
||||||
ullong bpc = ullong(spc) * ullong(bps);
|
ullong bpc = ullong(spc) * ullong(bps);
|
||||||
m.space_all = bpc * ullong(all_cl);
|
m.space_all = bpc * ullong(all_cl);
|
||||||
m.space_free = bpc * ullong(free_cl);
|
m.space_free = bpc * ullong(free_cl);
|
||||||
m.space_used = m.space_all - m.space_free;
|
m.space_used = m.space_all - m.space_free;
|
||||||
} else
|
} else
|
||||||
m.space_all = m.space_free = m.space_used = 0U;
|
m.space_all = m.space_free = m.space_used = 0U;
|
||||||
if (GetDriveType(clet.dataAscii()) == DRIVE_REMOVABLE)
|
if (GetDriveTypeA(clet.dataAscii()) == DRIVE_REMOVABLE)
|
||||||
m.removable = true;
|
m.removable = true;
|
||||||
clet.cutRight(1);
|
clet.cutRight(1);
|
||||||
int qdd = QueryDosDevice(clet.data(), volfs, 1023);
|
int qdd = QueryDosDeviceA(clet.data(), volfs, 1023);
|
||||||
if (qdd > 0)
|
if (qdd > 0)
|
||||||
m.device = volfs;
|
m.device = volfs;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void getCursor(int & x, int & y) {
|
|||||||
|
|
||||||
int main (int argc, char * argv[]) {
|
int main (int argc, char * argv[]) {
|
||||||
//piCout << "start";
|
//piCout << "start";
|
||||||
STARTUPINFO si;
|
STARTUPINFOA si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
memset(&pi, 0, sizeof(pi));
|
memset(&pi, 0, sizeof(pi));
|
||||||
@@ -245,7 +245,7 @@ int main (int argc, char * argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
PISharedMemory shm("piterm_aux" + shmh, 1024*1024);
|
PISharedMemory shm("piterm_aux" + shmh, 1024*1024);
|
||||||
pipe = CreateFile((LPSTR)pname.dataAscii(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
pipe = CreateFileA((LPSTR)pname.dataAscii(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
|
||||||
if (pipe == INVALID_HANDLE_VALUE) {
|
if (pipe == INVALID_HANDLE_VALUE) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user