#include #include "AtomicEditor.h" #include #include #include #include #include "FileUtils.h" #include "nfd.h" namespace AtomicEditor { FileUtils::FileUtils(Context* context) : Object(context) { } FileUtils::~FileUtils() { } void FileUtils::OpenProjectFileDialog() { nfdchar_t *outPath = NULL; nfdresult_t result = NFD_OpenDialog( "atomic", NULL, &outPath); if (outPath && result == NFD_OKAY) { String fullpath = outPath; //Editor* editor = GetSubsystem(); //editor->LoadProject(fullpath); } GetSubsystem()->RaiseWindow(); if (outPath) free(outPath); } bool FileUtils::CreateDirs(const String& folder) { FileSystem* fileSystem = GetSubsystem(); Poco::File dirs(folder.CString()); dirs.createDirectories(); return fileSystem->DirExists(folder); } String FileUtils::NewProjectFileDialog() { String projectPath; nfdchar_t *outPath = NULL; nfdresult_t result = NFD_ChooseDirectory( "Please choose the root folder for your project", NULL, &outPath); if (outPath && result == NFD_OKAY) { projectPath = outPath; } GetSubsystem()->RaiseWindow(); if (outPath) free(outPath); return projectPath; } void FileUtils::RevealInFinder(const String& fullpath) { FileSystem* fs = GetSubsystem(); if (fs->DirExists(fullpath)) fs->SystemOpen(fullpath); else if (fs->FileExists(fullpath)) fs->SystemOpen(GetPath(fullpath)); } }