mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-07-10 09:17:02 +00:00
feat: implement recursive folder traversal for file indexing
The previous implementation only indexed files in the root directory, ignoring files in subdirectories. This change adds recursive traversal to index all files within the folder hierarchy while maintaining relative paths for compatibility.
This commit is contained in:
parent
566f7ba683
commit
192c2a3c5c
|
|
@ -1,4 +1,4 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "../Minecraft.World/StringHelpers.h"
|
||||
#include "../Minecraft.World/compression.h"
|
||||
|
|
@ -7,7 +7,12 @@
|
|||
|
||||
void FolderFile::_buildFileIndex()
|
||||
{
|
||||
wstring searchPath = m_folderPath + L"\\*";
|
||||
_buildFileIndexRecursive(m_folderPath, L"");
|
||||
}
|
||||
|
||||
void FolderFile::_buildFileIndexRecursive(const wstring& currentPath, const wstring& relativePath)
|
||||
{
|
||||
wstring searchPath = currentPath + L"\\*";
|
||||
WIN32_FIND_DATAW findData;
|
||||
HANDLE hFind = FindFirstFileW(searchPath.c_str(), &findData);
|
||||
|
||||
|
|
@ -19,13 +24,20 @@ void FolderFile::_buildFileIndex()
|
|||
|
||||
do
|
||||
{
|
||||
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
if (wcscmp(findData.cFileName, L".") == 0 || wcscmp(findData.cFileName, L"..") == 0)
|
||||
continue;
|
||||
|
||||
wstring filename = findData.cFileName;
|
||||
wstring fullRelativePath = relativePath.empty() ? filename : relativePath + L"\\" + filename;
|
||||
wstring fullPath = currentPath + L"\\" + filename;
|
||||
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
wstring filename = findData.cFileName;
|
||||
wstring fullPath = m_folderPath + L"\\" + filename;
|
||||
|
||||
// Store filename without path for compatibility with existing code
|
||||
m_filePaths[filename] = fullPath;
|
||||
_buildFileIndexRecursive(fullPath, fullRelativePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_filePaths[fullRelativePath] = fullPath;
|
||||
}
|
||||
} while (FindNextFileW(hFind, &findData));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
|
@ -15,6 +15,7 @@ private:
|
|||
unordered_map<wstring, wstring> m_filePaths; // filename -> full path
|
||||
|
||||
void _buildFileIndex();
|
||||
void _buildFileIndexRecursive(const wstring& currentPath, const wstring& relativePath);
|
||||
|
||||
public:
|
||||
FolderFile(wstring folderPath);
|
||||
|
|
|
|||
Loading…
Reference in a new issue