More C++11ification.
This commit is contained in:
@@ -30,12 +30,12 @@ xe_file_ref xe_file_open(const xe_file_mode mode, const xechar_t *path) {
|
||||
xechar_t mode_string[10];
|
||||
mode_string[0] = 0;
|
||||
if (mode & kXEFileModeRead) {
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), XT("r")));
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), L"r"));
|
||||
}
|
||||
if (mode & kXEFileModeWrite) {
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), XT("w")));
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), L"w"));
|
||||
}
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), XT("b")));
|
||||
XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), L"b"));
|
||||
|
||||
#if XE_LIKE_WIN32 && XE_WCHAR
|
||||
XEEXPECTZERO(_wfopen_s((FILE**)&file->handle, path, mode_string));
|
||||
|
||||
@@ -75,7 +75,7 @@ int xe_pal_get_system_info(xe_system_info* out_info) {
|
||||
LPFN_GLPI glpi = NULL;
|
||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL;
|
||||
|
||||
kernel32 = GetModuleHandle(TEXT("kernel32"));
|
||||
kernel32 = GetModuleHandle(L"kernel32");
|
||||
XEEXPECTNOTNULL(kernel32);
|
||||
glpi = (LPFN_GLPI)GetProcAddress(kernel32, "GetLogicalProcessorInformation");
|
||||
XEEXPECTNOTNULL(glpi);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
void xe_path_join(const xechar_t* left, const xechar_t* right,
|
||||
xechar_t* out_path, size_t out_path_size) {
|
||||
#if XE_WCHAR
|
||||
xesnprintf(out_path, out_path_size, XT("%ls%c%ls"),
|
||||
left, XE_PATH_SEPARATOR, right);
|
||||
xesnprintf(out_path, out_path_size, L"%ls%c%ls",
|
||||
left, poly::path_separator, right);
|
||||
#else
|
||||
xesnprintf(out_path, out_path_size, XT("%s%c%s"),
|
||||
left, XE_PATH_SEPARATOR, right);
|
||||
xesnprintf(out_path, out_path_size, L"%s%c%s",
|
||||
left, poly::path_separator, right);
|
||||
#endif // XE_WCHAR
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ X_STATUS Emulator::LaunchXexFile(const xechar_t* path) {
|
||||
int result_code = 0;
|
||||
|
||||
// Get just the filename (foo.xex).
|
||||
const xechar_t* file_name = xestrrchr(path, XE_PATH_SEPARATOR);
|
||||
const xechar_t* file_name = xestrrchr(path, poly::path_separator);
|
||||
if (file_name) {
|
||||
// Skip slash.
|
||||
file_name++;
|
||||
@@ -157,7 +157,7 @@ X_STATUS Emulator::LaunchXexFile(const xechar_t* path) {
|
||||
}
|
||||
|
||||
// Get the parent path of the file.
|
||||
xechar_t parent_path[XE_MAX_PATH];
|
||||
xechar_t parent_path[poly::max_path];
|
||||
XEIGNORE(xestrcpy(parent_path, XECOUNT(parent_path), path));
|
||||
parent_path[file_name - path] = 0;
|
||||
|
||||
@@ -176,7 +176,7 @@ X_STATUS Emulator::LaunchXexFile(const xechar_t* path) {
|
||||
"d:", "\\Device\\Harddisk1\\Partition0");
|
||||
|
||||
// Get the file name of the module to load from the filesystem.
|
||||
char fs_path[XE_MAX_PATH];
|
||||
char fs_path[poly::max_path];
|
||||
XEIGNORE(xestrcpya(fs_path, XECOUNT(fs_path), "game:\\"));
|
||||
char* fs_path_ptr = fs_path + xestrlena(fs_path);
|
||||
*fs_path_ptr = 0;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
X_STATUS LaunchSTFSTitle(const xechar_t* path);
|
||||
|
||||
private:
|
||||
xechar_t command_line_[XE_MAX_PATH];
|
||||
xechar_t command_line_[poly::max_path];
|
||||
|
||||
ui::Window* main_window_;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ ID3D10Blob* D3D11GeometryShader::Compile(const char* shader_source) {
|
||||
base_path = FLAGS_dump_shaders.c_str();
|
||||
}
|
||||
uint64_t hash = xe_hash64(shader_source, xestrlena(shader_source)); // ?
|
||||
char file_name[XE_MAX_PATH];
|
||||
char file_name[poly::max_path];
|
||||
xesnprintfa(file_name, XECOUNT(file_name),
|
||||
"%s/gen_%.16llX.gs",
|
||||
base_path,
|
||||
|
||||
@@ -47,7 +47,7 @@ ID3D10Blob* D3D11ShaderCompile(XE_GPU_SHADER_TYPE type,
|
||||
base_path = FLAGS_dump_shaders.c_str();
|
||||
}
|
||||
size_t hash = xe_hash64(disasm_source, xestrlena(disasm_source)); // ?
|
||||
char file_name[XE_MAX_PATH];
|
||||
char file_name[poly::max_path];
|
||||
xesnprintfa(file_name, XECOUNT(file_name),
|
||||
"%s/gen_%.16llX.%s",
|
||||
base_path,
|
||||
|
||||
@@ -62,7 +62,7 @@ Entry* DiscImageDevice::ResolvePath(const char* path) {
|
||||
|
||||
// Walk the path, one separator at a time.
|
||||
// We copy it into the buffer and shift it left over and over.
|
||||
char remaining[XE_MAX_PATH];
|
||||
char remaining[poly::max_path];
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
|
||||
while (remaining[0]) {
|
||||
char* next_slash = xestrchra(remaining, '\\');
|
||||
|
||||
@@ -35,23 +35,23 @@ Entry* HostPathDevice::ResolvePath(const char* path) {
|
||||
XELOGFS("HostPathDevice::ResolvePath(%s)", path);
|
||||
|
||||
#if XE_WCHAR
|
||||
xechar_t rel_path[XE_MAX_PATH];
|
||||
xechar_t rel_path[poly::max_path];
|
||||
XEIGNORE(xestrwiden(rel_path, XECOUNT(rel_path), path));
|
||||
#else
|
||||
const xechar_t* rel_path = path;
|
||||
#endif
|
||||
|
||||
xechar_t full_path[XE_MAX_PATH];
|
||||
xechar_t full_path[poly::max_path];
|
||||
xe_path_join(local_path_, rel_path, full_path, XECOUNT(full_path));
|
||||
|
||||
// Swap around path separators.
|
||||
if (XE_PATH_SEPARATOR != '\\') {
|
||||
if (poly::path_separator != '\\') {
|
||||
for (size_t n = 0; n < XECOUNT(full_path); n++) {
|
||||
if (full_path[n] == 0) {
|
||||
break;
|
||||
}
|
||||
if (full_path[n] == '\\') {
|
||||
full_path[n] = XE_PATH_SEPARATOR;
|
||||
full_path[n] = poly::path_separator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ X_STATUS HostPathEntry::QueryDirectory(
|
||||
}
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
xechar_t target_path[XE_MAX_PATH];
|
||||
xestrcpy(target_path, XE_MAX_PATH, local_path_);
|
||||
xechar_t target_path[poly::max_path];
|
||||
xestrcpy(target_path, poly::max_path, local_path_);
|
||||
if (file_name == NULL) {
|
||||
xestrcat(target_path, XE_MAX_PATH, XETEXT("*"));
|
||||
xestrcat(target_path, poly::max_path, L"*");
|
||||
}
|
||||
else {
|
||||
auto target_length = xestrlen(local_path_);
|
||||
|
||||
@@ -63,7 +63,7 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) {
|
||||
|
||||
// Walk the path, one separator at a time.
|
||||
// We copy it into the buffer and shift it left over and over.
|
||||
char remaining[XE_MAX_PATH];
|
||||
char remaining[poly::max_path];
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
|
||||
while (remaining[0]) {
|
||||
char* next_slash = xestrchra(remaining, '\\');
|
||||
|
||||
@@ -91,7 +91,7 @@ Entry* FileSystem::ResolvePath(const char* path) {
|
||||
// Resolve symlinks.
|
||||
// TODO(benvanik): more robust symlink handling - right now we assume simple
|
||||
// drive path -> device mappings with nothing nested.
|
||||
char full_path[XE_MAX_PATH];
|
||||
char full_path[poly::max_path];
|
||||
XEIGNORE(xestrcpya(full_path, XECOUNT(full_path), path));
|
||||
for (std::unordered_map<std::string, std::string>::iterator it =
|
||||
symlinks_.begin(); it != symlinks_.end(); ++it) {
|
||||
@@ -111,7 +111,7 @@ Entry* FileSystem::ResolvePath(const char* path) {
|
||||
if (xestrcasestra(full_path, device->path()) == full_path) {
|
||||
// Found!
|
||||
// Trim the device prefix off and pass down.
|
||||
char device_path[XE_MAX_PATH];
|
||||
char device_path[poly::max_path];
|
||||
XEIGNORE(xestrcpya(device_path, XECOUNT(device_path),
|
||||
full_path + xestrlena(device->path())));
|
||||
return device->ResolvePath(device_path);
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
protected:
|
||||
char name_[256];
|
||||
char path_[XE_MAX_PATH];
|
||||
char path_[poly::max_path];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void xe_format_log_line(
|
||||
const char* function_name, const char level_char,
|
||||
const char* fmt, va_list args) {
|
||||
// Strip out just the filename from the path.
|
||||
const char* filename = xestrrchra(file_path, XE_PATH_SEPARATOR);
|
||||
const char* filename = xestrrchra(file_path, poly::path_separator);
|
||||
if (filename) {
|
||||
// Slash - skip over it.
|
||||
filename++;
|
||||
|
||||
@@ -94,7 +94,7 @@ int xe_main_window_thunk(
|
||||
xe_attach_console();
|
||||
wchar_t buffer[2048];
|
||||
xestrcpy(buffer, XECOUNT(buffer), name);
|
||||
xestrcat(buffer, XECOUNT(buffer), XETEXT(" "));
|
||||
xestrcat(buffer, XECOUNT(buffer), L" ");
|
||||
xestrcat(buffer, XECOUNT(buffer), command_line);
|
||||
int argc;
|
||||
wchar_t** argv = CommandLineToArgvW(buffer, &argc);
|
||||
|
||||
@@ -40,7 +40,6 @@ char* xestrcasestra(const char* str, const char* substr);
|
||||
#define xestrdupw _wcsdup
|
||||
#define xestrchrw wcschr
|
||||
#define xestrrchrw wcsrchr
|
||||
#define xestrstrw wcsstr
|
||||
#define xestrcasestrw ??
|
||||
#define xestrcpyw(dest, destLength, source) (wcscpy_s(dest, destLength, source) == 0)
|
||||
#define xestrncpyw(dest, destLength, source, count) (wcsncpy_s(dest, destLength, source, count) == 0)
|
||||
@@ -54,7 +53,6 @@ char* xestrcasestra(const char* str, const char* substr);
|
||||
#define xestrcasecmpa strcasecmp
|
||||
#define xestrchra strchr
|
||||
#define xestrrchra strrchr
|
||||
#define xestrstra strstr
|
||||
#define xestrcpya(dest, destLength, source) (strcpy_s(dest, destLength, source) == 0)
|
||||
#define xestrncpya(dest, destLength, source, count) (strncpy_s(dest, destLength, source, count) == 0)
|
||||
#define xestrcata(dest, destLength, source) (strcat_s(dest, destLength, source) == 0)
|
||||
@@ -65,8 +63,6 @@ char* xestrcasestra(const char* str, const char* substr);
|
||||
|
||||
typedef wchar_t xechar_t;
|
||||
#define XE_WCHAR 1
|
||||
#define XETEXT(s) L ## s
|
||||
#define XESTRFORMAT L"%ls"
|
||||
|
||||
#define xestrlen xestrlenw
|
||||
#define xestrcmp xestrcmpw
|
||||
@@ -74,7 +70,6 @@ typedef wchar_t xechar_t;
|
||||
#define xestrdup xestrdupw
|
||||
#define xestrchr xestrchrw
|
||||
#define xestrrchr xestrrchrw
|
||||
#define xestrstr xestrstrw
|
||||
#define xestrcasestr xestrcasestrw
|
||||
#define xestrtoull xestrtoullw
|
||||
#define xestrcpy xestrcpyw
|
||||
@@ -89,8 +84,6 @@ typedef wchar_t xechar_t;
|
||||
|
||||
typedef char xechar_t;
|
||||
#define XE_CHAR 1
|
||||
#define XETEXT(s) s
|
||||
#define XESTRFORMAT "%s"
|
||||
|
||||
#define xestrlen xestrlena
|
||||
#define xestrcmp xestrcmpa
|
||||
@@ -98,7 +91,6 @@ typedef char xechar_t;
|
||||
#define xestrdup xestrdupa
|
||||
#define xestrchr xestrchra
|
||||
#define xestrrchr xestrrchra
|
||||
#define xestrstr xestrstra
|
||||
#define xestrcasestr xestrcasestra
|
||||
#define xestrtoull xestrtoulla
|
||||
#define xestrcpy xestrcpya
|
||||
@@ -111,15 +103,4 @@ typedef char xechar_t;
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#define XT XETEXT
|
||||
#define XTS XESTRFORMAT
|
||||
|
||||
#if XE_LIKE_WIN32
|
||||
#define XE_PATH_SEPARATOR ((xechar_t)'\\')
|
||||
#define XE_MAX_PATH _MAX_PATH
|
||||
#else
|
||||
#define XE_PATH_SEPARATOR ((xechar_t)'/')
|
||||
#define XE_MAX_PATH PATH_MAX
|
||||
#endif // WIN32
|
||||
|
||||
#endif // XENIA_STRING_H_
|
||||
|
||||
Reference in New Issue
Block a user