yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
file_util.h
Go to the documentation of this file.
1#ifndef YAZE_UTIL_FILE_UTIL_H_
2#define YAZE_UTIL_FILE_UTIL_H_
3
4#include <functional>
5#include <string>
6#include <vector>
7
8namespace yaze {
9namespace util {
10
12 std::string label;
13 std::string spec; // Comma-delimited extensions (e.g., "sfc,smc") or "*".
14};
15
17 std::vector<FileDialogFilter> filters;
18};
19
21 public:
26 static std::string ShowOpenFileDialog();
27 static std::string ShowOpenFileDialog(const FileDialogOptions& options);
28 static void ShowOpenFileDialogAsync(
29 const FileDialogOptions& options,
30 std::function<void(const std::string&)> callback);
31
36 static std::string ShowOpenFolderDialog();
37
42 static std::string ShowSaveFileDialog(
43 const std::string& default_name = "",
44 const std::string& default_extension = "");
45
46 // Specific implementations for testing
47 static std::string ShowOpenFileDialogNFD();
48 static std::string ShowOpenFileDialogBespoke();
49 static std::string ShowSaveFileDialogNFD(
50 const std::string& default_name = "",
51 const std::string& default_extension = "");
52 static std::string ShowSaveFileDialogBespoke(
53 const std::string& default_name = "",
54 const std::string& default_extension = "");
55 static std::string ShowOpenFolderDialogNFD();
56 static std::string ShowOpenFolderDialogBespoke();
57 static std::vector<std::string> GetSubdirectoriesInFolder(
58 const std::string& folder_path);
59 static std::vector<std::string> GetFilesInFolder(
60 const std::string& folder_path);
61};
62
63FileDialogOptions MakeRomFileDialogOptions(bool include_all_files = true);
64
70
72
81std::string GetFileExtension(const std::string& filename);
82
91std::string GetFileName(const std::string& filename);
92std::string GetResourcePath(const std::string& resource_path);
93void SaveFile(const std::string& filename, const std::string& data);
94
103std::string LoadFile(const std::string& filename);
104
111std::string LoadFileFromConfigDir(const std::string& filename);
112
113} // namespace util
114} // namespace yaze
115
116#endif // YAZE_UTIL_FILE_UTIL_H_
static void ShowOpenFileDialogAsync(const FileDialogOptions &options, std::function< void(const std::string &)> callback)
static std::string ShowSaveFileDialogBespoke(const std::string &default_name="", const std::string &default_extension="")
static std::string ShowOpenFileDialogBespoke()
static std::string ShowSaveFileDialogNFD(const std::string &default_name="", const std::string &default_extension="")
static std::string ShowOpenFolderDialogNFD()
static std::string ShowSaveFileDialog(const std::string &default_name="", const std::string &default_extension="")
ShowSaveFileDialog opens a save file dialog and returns the selected filepath. Uses global feature fl...
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path. Uses global feature fl...
static std::vector< std::string > GetFilesInFolder(const std::string &folder_path)
static std::vector< std::string > GetSubdirectoriesInFolder(const std::string &folder_path)
static std::string ShowOpenFolderDialogBespoke()
static std::string ShowOpenFileDialogNFD()
void SaveFile(const std::string &filename, const std::string &contents)
Definition file_util.cc:56
std::string GetFileName(const std::string &filename)
Gets the filename from a full path.
Definition file_util.cc:19
std::string GetResourcePath(const std::string &resource_path)
Definition file_util.cc:70
std::string LoadFileFromConfigDir(const std::string &filename)
Loads a file from the user's config directory.
Definition file_util.cc:38
FileDialogOptions MakeRomFileDialogOptions(bool include_all_files)
Definition file_util.cc:87
std::string GetFileExtension(const std::string &filename)
Gets the file extension from a filename.
Definition file_util.cc:15
std::string GetBundleResourcePath()
GetBundleResourcePath returns the path to the bundle resource directory. Specific to MacOS.
std::string LoadFile(const std::string &filename)
Loads the entire contents of a file into a string.
Definition file_util.cc:23
std::vector< FileDialogFilter > filters
Definition file_util.h:17