mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
NK-92 - Update file system
This commit is contained in:
@@ -583,6 +583,22 @@ namespace Nuake
|
||||
const uint32_t numButtonAfterPathBrowser = 2;
|
||||
ImGui::SameLine();
|
||||
|
||||
char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, m_searchKeyWord.c_str(), sizeof(buffer));
|
||||
|
||||
if (ImGui::InputTextWithHint("##Search", "Asset search & filter ..", buffer, sizeof(buffer)))
|
||||
{
|
||||
m_searchKeyWord = std::string(buffer);
|
||||
FileSystem::FilteredDirectories = FileSystem::SearchFilesWithKeyword(m_searchKeyWord, FileSystem::RootDirectory->fullPath);
|
||||
RefreshFileBrowser();
|
||||
|
||||
// TODO: Fix when creating a new file
|
||||
}
|
||||
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4));
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Nuake {
|
||||
public:
|
||||
static Ref<Directory> m_CurrentDirectory;
|
||||
bool m_hasClickedOnFile;
|
||||
std::string m_searchKeyWord;
|
||||
|
||||
FileSystemUI(EditorInterface* editor)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Nuake
|
||||
std::string FileSystem::Root = "";
|
||||
|
||||
Ref<Directory> FileSystem::RootDirectory;
|
||||
std::vector<std::filesystem::path> FileSystem::FilteredDirectories;
|
||||
|
||||
void FileSystem::ScanDirectory(Ref<Directory> directory)
|
||||
{
|
||||
@@ -75,15 +76,15 @@ namespace Nuake
|
||||
}
|
||||
else if (entry.is_regular_file())
|
||||
{
|
||||
std::string absolutePath = entry.path().string();
|
||||
std::string name = entry.path().filename().string();
|
||||
std::string extension = entry.path().extension().string();
|
||||
Ref<File> newFile = CreateRef<File>(directory, absolutePath, name, extension);
|
||||
//newFile->Type = entry.path().extension().string();
|
||||
//newFile->name = entry.path().filename().string();
|
||||
//newFile->Parent = directory;
|
||||
//newFile->fullPath = entry.path().string();
|
||||
directory->Files.push_back(newFile);
|
||||
std::filesystem::path currentPath = entry.path();
|
||||
if (FilteredDirectories.empty() || std::find(FilteredDirectories.begin(), FilteredDirectories.end(), currentPath) != FilteredDirectories.end())
|
||||
{
|
||||
std::string absolutePath = currentPath.string();
|
||||
std::string name = currentPath.filename().string();
|
||||
std::string extension = currentPath.extension().string();
|
||||
Ref<File> newFile = CreateRef<File>(directory, absolutePath, name, extension);
|
||||
directory->Files.push_back(newFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,13 +230,15 @@ namespace Nuake
|
||||
return String::Split(split[split.size() - 1], '.')[0];
|
||||
}
|
||||
|
||||
void FileSystem::SearchFilesWithKeyword(const std::string& keyword, const std::string& directory) {
|
||||
std::vector<std::filesystem::path> FileSystem::SearchFilesWithKeyword(const std::string& keyword, const std::string& directory) {
|
||||
std::vector<std::filesystem::path> result;
|
||||
const std::string& sanitizedKeyword = String::Sanitize(keyword);
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(directory)) {
|
||||
if (entry.is_regular_file() && entry.path().filename().string().find(sanitizedKeyword) != std::string::npos) {
|
||||
std::cout << entry.path() << std::endl;
|
||||
result.push_back(entry.path());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Nuake
|
||||
static std::string Root;
|
||||
|
||||
static Ref<Directory> RootDirectory;
|
||||
static std::vector<std::filesystem::path> FilteredDirectories;
|
||||
|
||||
static void SetRootDirectory(const std::string path);
|
||||
|
||||
@@ -34,7 +35,7 @@ namespace Nuake
|
||||
static Ref<Directory> GetFileTree();
|
||||
static Ref<File> GetFile(const std::string& path);
|
||||
static std::string GetFileNameFromPath(const std::string& path);
|
||||
static void FileSystem::SearchFilesWithKeyword(const std::string& keyword, const std::string& directory);
|
||||
static std::vector<std::filesystem::path> FileSystem::SearchFilesWithKeyword(const std::string& keyword, const std::string& directory);
|
||||
static void ScanDirectory(Ref<Directory> directory);
|
||||
static void GetDirectories();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user