| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #include <Poco/File.h>
- #include "AtomicEditor.h"
- #include <Atomic/Core/Context.h>
- #include <Atomic/Core/StringUtils.h>
- #include <Atomic/IO/FileSystem.h>
- #include <Atomic/Graphics/Graphics.h>
- #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>();
- //editor->LoadProject(fullpath);
- }
- GetSubsystem<Graphics>()->RaiseWindow();
- if (outPath)
- free(outPath);
- }
- bool FileUtils::CreateDirs(const String& folder)
- {
- FileSystem* fileSystem = GetSubsystem<FileSystem>();
- 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<Graphics>()->RaiseWindow();
- if (outPath)
- free(outPath);
- return projectPath;
- }
- void FileUtils::RevealInFinder(const String& fullpath)
- {
- FileSystem* fs = GetSubsystem<FileSystem>();
- if (fs->DirExists(fullpath))
- fs->SystemOpen(fullpath);
- else if (fs->FileExists(fullpath))
- fs->SystemOpen(GetPath(fullpath));
- }
- }
|