2022-03-04 11:36:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-10-02 14:18:40 +02:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2022-03-04 11:36:37 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <filesystem>
|
2022-03-04 11:44:11 +01:00
|
|
|
#include <functional>
|
2022-03-04 11:36:37 +01:00
|
|
|
|
2023-03-12 18:27:29 +01:00
|
|
|
#include <wolv/io/fs.hpp>
|
2022-03-04 11:36:37 +01:00
|
|
|
|
|
|
|
namespace hex::fs {
|
|
|
|
|
2022-09-20 15:47:59 +02:00
|
|
|
enum class DialogMode {
|
2022-03-04 11:36:37 +01:00
|
|
|
Open,
|
|
|
|
Save,
|
|
|
|
Folder
|
|
|
|
};
|
|
|
|
|
2023-10-04 12:00:32 +02:00
|
|
|
struct ItemFilter {
|
|
|
|
// Human-friendly name
|
|
|
|
std::string name;
|
|
|
|
// Extensions that constitute this filter
|
|
|
|
std::string spec;
|
|
|
|
};
|
|
|
|
|
2023-03-26 11:02:51 +02:00
|
|
|
void setFileBrowserErrorCallback(const std::function<void(const std::string&)> &callback);
|
2023-10-04 12:00:32 +02:00
|
|
|
bool openFileBrowser(DialogMode mode, const std::vector<ItemFilter> &validExtensions, const std::function<void(std::fs::path)> &callback, const std::string &defaultPath = {}, bool multiple = false);
|
2022-03-04 11:36:37 +01:00
|
|
|
|
2023-05-21 13:21:53 +02:00
|
|
|
void openFileExternal(const std::fs::path &filePath);
|
|
|
|
void openFolderExternal(const std::fs::path &dirPath);
|
|
|
|
void openFolderWithSelectionExternal(const std::fs::path &selectedFilePath);
|
|
|
|
|
2022-10-02 14:18:40 +02:00
|
|
|
enum class ImHexPath : u32 {
|
|
|
|
Patterns = 0,
|
2022-03-04 11:36:37 +01:00
|
|
|
PatternsInclude,
|
|
|
|
Magic,
|
|
|
|
Plugins,
|
|
|
|
Yara,
|
2024-02-25 11:32:05 +01:00
|
|
|
YaraAdvancedAnalysis,
|
2022-03-04 11:36:37 +01:00
|
|
|
Config,
|
2023-12-11 11:42:33 +01:00
|
|
|
Backups,
|
2022-03-04 11:36:37 +01:00
|
|
|
Resources,
|
|
|
|
Constants,
|
|
|
|
Encodings,
|
2022-08-14 10:07:45 +02:00
|
|
|
Logs,
|
2022-10-02 14:18:40 +02:00
|
|
|
Recent,
|
|
|
|
Scripts,
|
|
|
|
Inspectors,
|
2022-12-29 19:26:00 +01:00
|
|
|
Themes,
|
2023-01-07 10:32:01 +01:00
|
|
|
Libraries,
|
2023-02-09 23:07:04 +01:00
|
|
|
Nodes,
|
2023-05-11 18:44:50 +02:00
|
|
|
Layouts,
|
2023-12-11 15:54:22 +01:00
|
|
|
Workspaces,
|
2022-10-02 14:18:40 +02:00
|
|
|
|
|
|
|
END
|
2022-03-04 11:36:37 +01:00
|
|
|
};
|
|
|
|
|
2023-03-12 18:27:29 +01:00
|
|
|
bool isPathWritable(const std::fs::path &path);
|
2022-03-04 11:36:37 +01:00
|
|
|
|
|
|
|
std::vector<std::fs::path> getDefaultPaths(ImHexPath path, bool listNonExisting = false);
|
|
|
|
|
2023-10-04 12:00:32 +02:00
|
|
|
// Temporarily expose these for the migration function
|
2023-03-26 11:02:23 +02:00
|
|
|
std::vector<std::fs::path> getDataPaths();
|
|
|
|
std::vector<std::fs::path> appendPath(std::vector<std::fs::path> paths, const std::fs::path &folder);
|
2022-03-04 11:36:37 +01:00
|
|
|
}
|