From 38ce933fd5ec05673cbefae63f2bae74a1e0d53c Mon Sep 17 00:00:00 2001 From: GuglioIsStupid Date: Sat, 7 Mar 2026 06:36:05 -0500 Subject: voids request - Move the filesystem files to root/ as it will be used in both Minecraft.Client and Minecraft.World (#819) * Move Filesystem to root/include/ as per devoiders request * Filesystem -> lce_filesystem --- include/lce_filesystem/lce_filesystem.cpp | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 include/lce_filesystem/lce_filesystem.cpp (limited to 'include/lce_filesystem/lce_filesystem.cpp') diff --git a/include/lce_filesystem/lce_filesystem.cpp b/include/lce_filesystem/lce_filesystem.cpp new file mode 100644 index 00000000..d0d4d600 --- /dev/null +++ b/include/lce_filesystem/lce_filesystem.cpp @@ -0,0 +1,73 @@ +#include "lce_filesystem.h" + +#ifdef _WINDOWS64 +#include +#endif // TODO: More os' filesystem handling for when the project moves away from only Windows + +#include + +bool FileOrDirectoryExists(const char* path) +{ +#ifdef _WINDOWS64 + DWORD attribs = GetFileAttributesA(path); + return (attribs != INVALID_FILE_ATTRIBUTES); +#else + #error "FileOrDirectoryExists not implemented for this platform" + return false; +#endif +} + +bool FileExists(const char* path) +{ +#ifdef _WINDOWS64 + DWORD attribs = GetFileAttributesA(path); + return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY)); +#else + #error "FileExists not implemented for this platform" + return false; +#endif +} + +bool DirectoryExists(const char* path) +{ +#ifdef _WINDOWS64 + DWORD attribs = GetFileAttributesA(path); + return (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY)); +#else + #error "DirectoryExists not implemented for this platform" + return false; +#endif +} + +bool GetFirstFileInDirectory(const char* directory, char* outFilePath, size_t outFilePathSize) +{ +#ifdef _WINDOWS64 + char searchPath[MAX_PATH]; + snprintf(searchPath, MAX_PATH, "%s\\*", directory); + + WIN32_FIND_DATAA findData; + HANDLE hFind = FindFirstFileA(searchPath, &findData); + + if (hFind == INVALID_HANDLE_VALUE) + { + return false; + } + + do + { + if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + // Found a file, copy its path to the output buffer + snprintf(outFilePath, outFilePathSize, "%s\\%s", directory, findData.cFileName); + FindClose(hFind); + return true; + } + } while (FindNextFileA(hFind, &findData) != 0); + + FindClose(hFind); + return false; // No files found in the directory +#else + #error "GetFirstFileInDirectory not implemented for this platform" + return false; +#endif +} -- cgit v1.2.3 From 220fe184874c67fe0899fcbdea9b5dd064c3669a Mon Sep 17 00:00:00 2001 From: GuglioIsStupid Date: Sat, 7 Mar 2026 08:21:37 -0500 Subject: Fix PCH (#828) --- Minecraft.Client/Minecraft.Client.vcxproj | 2 +- Minecraft.Client/Minecraft.Client.vcxproj.filters | 4 ++-- include/lce_filesystem/lce_filesystem.cpp | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include/lce_filesystem/lce_filesystem.cpp') diff --git a/Minecraft.Client/Minecraft.Client.vcxproj b/Minecraft.Client/Minecraft.Client.vcxproj index fccbc7dd..da03f0d9 100644 --- a/Minecraft.Client/Minecraft.Client.vcxproj +++ b/Minecraft.Client/Minecraft.Client.vcxproj @@ -1551,7 +1551,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata" - NotUsing + Use Level3 ProgramDatabase Disabled diff --git a/Minecraft.Client/Minecraft.Client.vcxproj.filters b/Minecraft.Client/Minecraft.Client.vcxproj.filters index ed71bfe0..23b754fa 100644 --- a/Minecraft.Client/Minecraft.Client.vcxproj.filters +++ b/Minecraft.Client/Minecraft.Client.vcxproj.filters @@ -3790,8 +3790,8 @@ Common\Source Files\Audio - - include\lce_filesystem + + Header Files diff --git a/include/lce_filesystem/lce_filesystem.cpp b/include/lce_filesystem/lce_filesystem.cpp index d0d4d600..e4dac0a0 100644 --- a/include/lce_filesystem/lce_filesystem.cpp +++ b/include/lce_filesystem/lce_filesystem.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "lce_filesystem.h" #ifdef _WINDOWS64 -- cgit v1.2.3