#include "node.h"
#include "platform.h"
+#include "platform_win32.h"
#include <sys/param.h> // for MAXPATHLEN
#include <unistd.h> // getpagesize
// Does the about the same as perror(), but for windows api functions
-static void _winapi_perror(const char* prefix = NULL) {
+void winapi_perror(const char* prefix = NULL) {
DWORD errno = GetLastError();
char *errmsg;
// Find out how big the buffer for the wide-char title must be
length = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0);
if (!length) {
- _winapi_perror("MultiByteToWideChar");
+ winapi_perror("MultiByteToWideChar");
return;
}
title_w = new WCHAR[length];
length = MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, length);
if (!length) {
- _winapi_perror("MultiByteToWideChar");
+ winapi_perror("MultiByteToWideChar");
delete title_w;
return;
};
}
if (!SetConsoleTitleW(title_w)) {
- _winapi_perror("SetConsoleTitleW");
+ winapi_perror("SetConsoleTitleW");
}
free(process_title);
// If length is zero, there may be an error or the title may be empty
if (!length_w) {
if (GetLastError()) {
- _winapi_perror("GetConsoleTitleW");
+ winapi_perror("GetConsoleTitleW");
return NULL;
}
else {
title_w = new WCHAR[length_w];
if (!GetConsoleTitleW(title_w, length_w * sizeof(WCHAR))) {
- _winapi_perror("GetConsoleTitleW");
+ winapi_perror("GetConsoleTitleW");
delete title_w;
return NULL;
}
// Find out what the size of the buffer is that we need
length = WideCharToMultiByte(CP_UTF8, 0, title_w, length_w, NULL, 0, NULL, NULL);
if (!length) {
- _winapi_perror("WideCharToMultiByte");
+ winapi_perror("WideCharToMultiByte");
delete title_w;
return NULL;
}
// Do utf16 -> utf8 conversion here
if (!WideCharToMultiByte(CP_UTF8, 0, title_w, -1, title, length, NULL, NULL)) {
- _winapi_perror("WideCharToMultiByte");
+ winapi_perror("WideCharToMultiByte");
delete title_w;
free(title);
return NULL;