Fix paths.

This commit is contained in:
Dario 2024-12-16 15:06:16 -03:00
parent 5512602231
commit 5d2f52a64c
4 changed files with 34 additions and 30 deletions

View file

@ -327,11 +327,23 @@ uint32_t XWriteFile(FileHandle* hFile, const void* lpBuffer, uint32_t nNumberOfB
return TRUE;
}
static void fixSlashes(char *path)
{
while (*path != 0)
{
if (*path == '\\')
{
*path = '/';
}
path++;
}
}
const char* FileSystem::TransformPath(const char* path)
{
thread_local char builtPath[2048]{};
const char* relativePath = strstr(path, ":\\");
if (relativePath != nullptr)
{
// rooted folder, handle direction
@ -343,12 +355,19 @@ const char* FileSystem::TransformPath(const char* path)
strncpy(builtPath, newRoot.data(), newRoot.size());
builtPath[newRoot.size()] = '\\';
strcpy(builtPath + newRoot.size() + 1, relativePath + 2);
return builtPath;
}
else
{
strncpy(builtPath, relativePath + 2, sizeof(builtPath));
}
}
else
{
strncpy(builtPath, path, sizeof(builtPath));
}
return relativePath != nullptr ? relativePath + 2 : path;
fixSlashes(builtPath);
return builtPath;
}
SWA_API const char* XExpandFilePathA(const char* path)

View file

@ -313,7 +313,7 @@ SWA_API uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName
}
else if (pContentData->dwContentType == XCONTENTTYPE_DLC)
{
root = ".\\dlc";
root = "./dlc";
}
else
{

View file

@ -50,8 +50,8 @@ void KiSystemStartup()
{
const auto gameContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Game");
const auto updateContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Update");
XamRegisterContent(gameContent, std::filesystem::exists(".\\game") ? ".\\game" : ".");
XamRegisterContent(updateContent, ".\\update");
XamRegisterContent(gameContent, std::filesystem::exists("./game") ? "./game" : ".");
XamRegisterContent(updateContent, "./update");
const auto savePath = GetSavePath();
const auto saveName = "SYS-DATA";
@ -69,27 +69,6 @@ void KiSystemStartup()
// OS mounts game data to D:
XamContentCreateEx(0, "D", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
//WIN32_FIND_DATAA fdata;
//const auto findHandle = FindFirstFileA(".\\dlc\\*.*", &fdata);
//if (findHandle != INVALID_HANDLE_VALUE)
//{
// char strBuf[256];
// do
// {
// if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0)
// {
// continue;
// }
// if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
// {
// snprintf(strBuf, sizeof(strBuf), ".\\dlc\\%s", fdata.cFileName);
// XamRegisterContent(XamMakeContent(XCONTENTTYPE_DLC, fdata.cFileName), strBuf);
// }
// } while (FindNextFileA(findHandle, &fdata));
// FindClose(findHandle);
//}
XAudioInitializeSystem();
}

View file

@ -2,10 +2,16 @@
void os::logger::detail::Init()
{
assert(false && "Unimplemented.");
}
void os::logger::detail::Log(const std::string_view str, detail::ELogType type, const char* func)
{
assert(false && "Unimplemented.");
if (func)
{
fmt::println("[{}] {}", func, str);
}
else
{
fmt::println("{}", str);
}
}