diff --git a/adapters/standalone.cpp b/adapters/standalone.cpp index d2ff09b0..277e09e3 100644 --- a/adapters/standalone.cpp +++ b/adapters/standalone.cpp @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) { // Check existence of the system res/ directory std::string resDir = asset::system("res"); - if (!system::isDir(resDir)) { + if (!system::isDirectory(resDir)) { std::string message = string::f("Rack's resource directory \"%s\" does not exist. Make sure Rack is correctly installed and launched.", resDir.c_str()); osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, message.c_str()); exit(1); diff --git a/include/engine/Module.hpp b/include/engine/Module.hpp index f61970f5..db30b431 100644 --- a/include/engine/Module.hpp +++ b/include/engine/Module.hpp @@ -224,8 +224,8 @@ struct Module { The Module must be added to Engine before this can be called, so it cannot be called in your Module constructor. Override onAdd() instead. */ - std::string createPatchStorageDir(); - std::string getPatchStorageDir(); + std::string createPatchStorageDirectory(); + std::string getPatchStorageDirectory(); struct ProcessArgs { /** The current sample rate in Hz. */ diff --git a/include/plugin/Model.hpp b/include/plugin/Model.hpp index 8e662f82..2bfaff47 100644 --- a/include/plugin/Model.hpp +++ b/include/plugin/Model.hpp @@ -58,8 +58,8 @@ struct Model { void fromJson(json_t* rootJ); /** Returns the branded name of the model, e.g. VCV VCO-1. */ std::string getFullName(); - std::string getFactoryPresetDir(); - std::string getUserPresetDir(); + std::string getFactoryPresetDirectory(); + std::string getUserPresetDirectory(); }; diff --git a/include/system.hpp b/include/system.hpp index 62001391..fe3852e2 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -32,7 +32,7 @@ bool exists(const std::string& path); /** Returns whether the given path is a file. */ bool isFile(const std::string& path); /** Returns whether the given path is a directory. */ -bool isDir(const std::string& path); +bool isDirectory(const std::string& path); uint64_t getFileSize(const std::string& path); /** Moves a file or directory. Does not overwrite the destination. If this behavior is needed, use remove() or removeRecursively() before moving. @@ -43,10 +43,10 @@ void copy(const std::string& srcPath, const std::string& destPath); /** Creates a directory. The parent directory must exist. */ -bool createDir(const std::string& path); +bool createDirectory(const std::string& path); /** Creates all directories up to the path. */ -bool createDirs(const std::string& path); +bool createDirectories(const std::string& path); /** Deletes a file or empty directory. Returns whether the deletion was successful. */ @@ -55,9 +55,9 @@ bool remove(const std::string& path); Returns the number of files and directories that were deleted. */ int removeRecursively(const std::string& path); -std::string getWorkingDir(); -void setWorkingDir(const std::string& path); -std::string getTempDir(); +std::string getWorkingDirectory(); +void setWorkingDirectory(const std::string& path); +std::string getTempDirectory(); /** Returns the absolute path beginning with "/". */ std::string getAbsolute(const std::string& path); /** Returns the canonical (unique) path, following symlinks and "." and ".." fake directories. @@ -68,11 +68,11 @@ Examples: std::string getCanonical(const std::string& path); /** Extracts the parent directory of the path. Examples: - getDir("/var/tmp/example.txt") // "/var/tmp" - getDir("/") // "" - getDir("/var/tmp/.") // "/var/tmp" + getDirectory("/var/tmp/example.txt") // "/var/tmp" + getDirectory("/") // "" + getDirectory("/var/tmp/.") // "/var/tmp" */ -std::string getDir(const std::string& path); +std::string getDirectory(const std::string& path); /** Extracts the filename of the path. Examples: getFilename("/foo/bar.txt") // "bar.txt" @@ -112,15 +112,15 @@ An equivalent shell command is ZSTD_CLEVEL=1 tar -cf archivePath --zstd -C dirPath . */ -void archiveDir(const std::string& archivePath, const std::string& dirPath, int compressionLevel = 1); -std::vector archiveDir(const std::string& dirPath, int compressionLevel = 1); +void archiveDirectory(const std::string& archivePath, const std::string& dirPath, int compressionLevel = 1); +std::vector archiveDirectory(const std::string& dirPath, int compressionLevel = 1); /** Extracts an archive into a directory. An equivalent shell command is tar -xf archivePath --zstd -C dirPath */ -void unarchiveToDir(const std::string& archivePath, const std::string& dirPath); -void unarchiveToDir(const std::vector& archiveData, const std::string& dirPath); +void unarchiveToDirectory(const std::string& archivePath, const std::string& dirPath); +void unarchiveToDirectory(const std::vector& archiveData, const std::string& dirPath); // Threading @@ -151,7 +151,7 @@ May block, so open in a new thread. */ void openBrowser(const std::string& url); /** Opens Windows Explorer, Finder, etc at a directory location. */ -void openDir(const std::string& path); +void openDirectory(const std::string& path); /** Runs an executable without blocking. The launched process will continue running if the current process is closed. */ diff --git a/src/Window.cpp b/src/Window.cpp index 6d2c90d1..2d5665ea 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -530,10 +530,10 @@ void Window::screenshot(const std::string& screenshotPath) { void Window::screenshotModules(const std::string& screenshotsDir, float zoom) { // Iterate plugins and create directories - system::createDirs(screenshotsDir); + system::createDirectories(screenshotsDir); for (plugin::Plugin* p : plugin::plugins) { std::string dir = system::join(screenshotsDir, p->slug); - system::createDir(dir); + system::createDirectory(dir); for (plugin::Model* model : p->models) { std::string filename = system::join(dir, model->slug + ".png"); diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index c86adcd3..47c83154 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -74,7 +74,7 @@ struct DirItem : ui::MenuItem { std::string path; void onAction(const ActionEvent& e) override { std::thread t([=] { - system::openDir(path); + system::openDirectory(path); }); t.detach(); } diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 73874de6..e2aa677b 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -41,7 +41,7 @@ struct ModuleDirItem : ui::MenuItem { std::string path; void onAction(const ActionEvent& e) override { std::thread t([=]() { - system::openDir(path); + system::openDirectory(path); }); t.detach(); } @@ -288,14 +288,14 @@ struct ModulePresetDirItem : ui::MenuItem { static void appendPresetItems(ui::Menu* menu, WeakPtr moduleWidget, std::string presetDir) { bool hasPresets = false; // Note: This is not cached, so opening this menu each time might have a bit of latency. - if (system::isDir(presetDir)) { + if (system::isDirectory(presetDir)) { for (const std::string& path : system::getEntries(presetDir)) { std::string name = system::getStem(path); // Remove "1_", "42_", "001_", etc at the beginning of preset filenames std::regex r("^\\d*_"); name = std::regex_replace(name, r, ""); - if (system::isDir(path)) { + if (system::isDirectory(path)) { hasPresets = true; ModulePresetDirItem* dirItem = new ModulePresetDirItem; @@ -365,12 +365,12 @@ struct ModulePresetItem : ui::MenuItem { // Scan `/presets//` for presets. menu->addChild(new ui::MenuSeparator); menu->addChild(createMenuLabel("User presets")); - appendPresetItems(menu, moduleWidget, moduleWidget->model->getUserPresetDir()); + appendPresetItems(menu, moduleWidget, moduleWidget->model->getUserPresetDirectory()); // Scan `/presets/` for presets. menu->addChild(new ui::MenuSeparator); menu->addChild(createMenuLabel("Factory presets")); - appendPresetItems(menu, moduleWidget, moduleWidget->model->getFactoryPresetDir()); + appendPresetItems(menu, moduleWidget, moduleWidget->model->getFactoryPresetDirectory()); return menu; } @@ -836,7 +836,7 @@ void ModuleWidget::loadAction(std::string filename) { } void ModuleWidget::loadTemplate() { - std::string templatePath = system::join(model->getUserPresetDir(), "template.vcvm"); + std::string templatePath = system::join(model->getUserPresetDirectory(), "template.vcvm"); try { load(templatePath); } @@ -846,14 +846,14 @@ void ModuleWidget::loadTemplate() { } void ModuleWidget::loadDialog() { - std::string presetDir = model->getUserPresetDir(); - system::createDirs(presetDir); + std::string presetDir = model->getUserPresetDirectory(); + system::createDirectories(presetDir); // Delete directories if empty DEFER({ try { system::remove(presetDir); - system::remove(system::getDir(presetDir)); + system::remove(system::getDirectory(presetDir)); } catch (Exception& e) { // Ignore exceptions if directory cannot be removed. @@ -897,8 +897,8 @@ void ModuleWidget::save(std::string filename) { } void ModuleWidget::saveTemplate() { - std::string presetDir = model->getUserPresetDir(); - system::createDirs(presetDir); + std::string presetDir = model->getUserPresetDirectory(); + system::createDirectories(presetDir); std::string templatePath = system::join(presetDir, "template.vcvm"); save(templatePath); } @@ -913,13 +913,13 @@ void ModuleWidget::saveTemplateDialog() { } bool ModuleWidget::hasTemplate() { - std::string presetDir = model->getUserPresetDir(); + std::string presetDir = model->getUserPresetDirectory(); std::string templatePath = system::join(presetDir, "template.vcvm"); return system::exists(templatePath);; } void ModuleWidget::clearTemplate() { - std::string presetDir = model->getUserPresetDir(); + std::string presetDir = model->getUserPresetDirectory(); std::string templatePath = system::join(presetDir, "template.vcvm"); system::remove(templatePath); } @@ -932,14 +932,14 @@ void ModuleWidget::clearTemplateDialog() { } void ModuleWidget::saveDialog() { - std::string presetDir = model->getUserPresetDir(); - system::createDirs(presetDir); + std::string presetDir = model->getUserPresetDirectory(); + system::createDirectories(presetDir); // Delete directories if empty DEFER({ try { system::remove(presetDir); - system::remove(system::getDir(presetDir)); + system::remove(system::getDirectory(presetDir)); } catch (Exception& e) { // Ignore exceptions if directory cannot be removed. diff --git a/src/asset.cpp b/src/asset.cpp index d49e876e..5f580aeb 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -34,7 +34,7 @@ static void initSystemDir() { return; if (settings::devMode) { - systemDir = system::getWorkingDir(); + systemDir = system::getWorkingDirectory(); return; } @@ -71,7 +71,7 @@ static void initSystemDir() { #endif #if defined ARCH_LIN // Use the current working directory as the default path on Linux. - systemDir = system::getWorkingDir(); + systemDir = system::getWorkingDirectory(); #endif } @@ -114,7 +114,7 @@ void init() { initSystemDir(); initUserDir(); - system::createDir(userDir); + system::createDirectory(userDir); } diff --git a/src/engine/Module.cpp b/src/engine/Module.cpp index 4cf2649e..9395c197 100644 --- a/src/engine/Module.cpp +++ b/src/engine/Module.cpp @@ -82,14 +82,14 @@ void Module::config(int numParams, int numInputs, int numOutputs, int numLights) } -std::string Module::createPatchStorageDir() { - std::string path = getPatchStorageDir(); - system::createDirs(path); +std::string Module::createPatchStorageDirectory() { + std::string path = getPatchStorageDirectory(); + system::createDirectories(path); return path; } -std::string Module::getPatchStorageDir() { +std::string Module::getPatchStorageDirectory() { return system::join(APP->patch->autosavePath, "modules", std::to_string(id)); } diff --git a/src/patch.cpp b/src/patch.cpp index b806b693..cca03c4c 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -99,7 +99,7 @@ void PatchManager::save(std::string path) { double startTime = system::getTime(); // Set compression level to 1 so that a 500MB/s SSD is almost bottlenecked - system::archiveDir(path, autosavePath, 1); + system::archiveDirectory(path, autosavePath, 1); double endTime = system::getTime(); INFO("Archived patch in %lf seconds", (endTime - startTime)); } @@ -130,11 +130,11 @@ void PatchManager::saveAsDialog() { std::string filename; if (this->path == "") { dir = asset::user("patches"); - system::createDirs(dir); + system::createDirectories(dir); filename = "Untitled.vcv"; } else { - dir = system::getDir(this->path); + dir = system::getDirectory(this->path); filename = system::getFilename(this->path); } @@ -195,7 +195,7 @@ void PatchManager::saveAutosave() { DEFER({json_decref(rootJ);}); // Write to temporary path and then rename it to the correct path - system::createDirs(autosavePath); + system::createDirectories(autosavePath); std::string tmpPath = patchPath + ".tmp"; FILE* file = std::fopen(tmpPath.c_str(), "w"); if (!file) { @@ -213,7 +213,7 @@ void PatchManager::saveAutosave() { void PatchManager::cleanAutosave() { // Remove files and directories in the `autosave/modules` directory that doesn't match a module in the rack. std::string modulesDir = system::join(autosavePath, "modules"); - if (system::isDir(modulesDir)) { + if (system::isDirectory(modulesDir)) { for (const std::string& entry : system::getEntries(modulesDir)) { try { int64_t moduleId = std::stol(system::getFilename(entry)); @@ -248,7 +248,7 @@ void PatchManager::load(std::string path) { INFO("Loading patch %s", path.c_str()); system::removeRecursively(autosavePath); - system::createDirs(autosavePath); + system::createDirectories(autosavePath); if (isPatchLegacyV1(path)) { // Copy the .vcv file directly to "patch.json". @@ -257,7 +257,7 @@ void PatchManager::load(std::string path) { else { // Extract the .vcv file as a .tar.zst archive. double startTime = system::getTime(); - system::unarchiveToDir(path, autosavePath); + system::unarchiveToDirectory(path, autosavePath); double endTime = system::getTime(); INFO("Unarchived patch in %lf seconds", (endTime - startTime)); } @@ -348,10 +348,10 @@ void PatchManager::loadDialog() { std::string dir; if (this->path == "") { dir = asset::user("patches"); - system::createDir(dir); + system::createDirectory(dir); } else { - dir = system::getDir(this->path); + dir = system::getDirectory(this->path); } osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); diff --git a/src/plugin.cpp b/src/plugin.cpp index 99598f93..44df9239 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -53,10 +53,10 @@ static void* loadLibrary(std::string libraryPath) { } #else // As of Rack v2.0, plugins are linked with `-rpath=.` so change current directory so it can find libRack. - std::string cwd = system::getWorkingDir(); - system::setWorkingDir(asset::systemDir); + std::string cwd = system::getWorkingDirectory(); + system::setWorkingDirectory(asset::systemDir); // Change it back when we're finished - DEFER({system::setWorkingDir(cwd);}); + DEFER({system::setWorkingDirectory(cwd);}); // Load library with dlopen void* handle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); if (!handle) @@ -166,7 +166,7 @@ static Plugin* loadPlugin(std::string path) { static void loadPlugins(std::string path) { for (std::string pluginPath : system::getEntries(path)) { - if (!system::isDir(pluginPath)) + if (!system::isDirectory(pluginPath)) continue; if (!loadPlugin(pluginPath)) { // Ignore bad plugins. They are reported in the log. @@ -187,7 +187,7 @@ static void extractPackages(std::string path) { // Extract package INFO("Extracting package %s", packagePath.c_str()); try { - system::unarchiveToDir(packagePath, path); + system::unarchiveToDirectory(packagePath, path); } catch (Exception& e) { WARN("Plugin package %s failed to extract: %s", packagePath.c_str(), e.what()); @@ -221,7 +221,7 @@ void init() { } // Get user plugins directory - system::createDir(pluginsPath); + system::createDirectory(pluginsPath); // Extract packages and load plugins extractPackages(pluginsPath); @@ -232,7 +232,7 @@ void init() { std::string fundamentalDir = system::join(pluginsPath, "Fundamental"); if (!settings::devMode && !getPlugin("Fundamental") && system::isFile(fundamentalSrc)) { INFO("Extracting bundled Fundamental package"); - system::unarchiveToDir(fundamentalSrc.c_str(), pluginsPath.c_str()); + system::unarchiveToDirectory(fundamentalSrc.c_str(), pluginsPath.c_str()); loadPlugin(fundamentalDir); } } diff --git a/src/plugin/Model.cpp b/src/plugin/Model.cpp index 86ab3987..e4348a15 100644 --- a/src/plugin/Model.cpp +++ b/src/plugin/Model.cpp @@ -63,12 +63,12 @@ std::string Model::getFullName() { } -std::string Model::getFactoryPresetDir() { +std::string Model::getFactoryPresetDirectory() { return asset::plugin(plugin, system::join("presets", slug)); } -std::string Model::getUserPresetDir() { +std::string Model::getUserPresetDirectory() { return asset::user(system::join("presets", plugin->slug, slug)); } diff --git a/src/system.cpp b/src/system.cpp index c61c442f..824f53b0 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -100,7 +100,7 @@ bool isFile(const std::string& path) { } -bool isDir(const std::string& path) { +bool isDirectory(const std::string& path) { try { return fs::is_directory(fs::u8path(path)); } @@ -140,7 +140,7 @@ void copy(const std::string& srcPath, const std::string& destPath) { } -bool createDir(const std::string& path) { +bool createDirectory(const std::string& path) { try { return fs::create_directory(fs::u8path(path)); } @@ -150,7 +150,7 @@ bool createDir(const std::string& path) { } -bool createDirs(const std::string& path) { +bool createDirectories(const std::string& path) { try { return fs::create_directories(fs::u8path(path)); } @@ -180,7 +180,7 @@ int removeRecursively(const std::string& path) { } -std::string getWorkingDir() { +std::string getWorkingDirectory() { try { return fs::current_path().generic_u8string(); } @@ -190,7 +190,7 @@ std::string getWorkingDir() { } -void setWorkingDir(const std::string& path) { +void setWorkingDirectory(const std::string& path) { try { fs::current_path(fs::u8path(path)); } @@ -200,7 +200,7 @@ void setWorkingDir(const std::string& path) { } -std::string getTempDir() { +std::string getTempDirectory() { try { return fs::temp_directory_path().generic_u8string(); } @@ -230,7 +230,7 @@ std::string getCanonical(const std::string& path) { } -std::string getDir(const std::string& path) { +std::string getDirectory(const std::string& path) { try { return fs::u8path(path).parent_path().generic_u8string(); } @@ -300,7 +300,7 @@ static la_ssize_t archiveWriteVectorCallback(struct archive* a, void* client_dat } -static void archiveDir(const std::string& archivePath, std::vector* archiveData, const std::string& dirPath, int compressionLevel) { +static void archiveDirectory(const std::string& archivePath, std::vector* archiveData, const std::string& dirPath, int compressionLevel) { // Based on minitar.c create() in libarchive examples int r; @@ -394,13 +394,13 @@ static void archiveDir(const std::string& archivePath, std::vector* arc } } -void archiveDir(const std::string& archivePath, const std::string& dirPath, int compressionLevel) { - archiveDir(archivePath, NULL, dirPath, compressionLevel); +void archiveDirectory(const std::string& archivePath, const std::string& dirPath, int compressionLevel) { + archiveDirectory(archivePath, NULL, dirPath, compressionLevel); } -std::vector archiveDir(const std::string& dirPath, int compressionLevel) { +std::vector archiveDirectory(const std::string& dirPath, int compressionLevel) { std::vector archiveData; - archiveDir("", &archiveData, dirPath, compressionLevel); + archiveDirectory("", &archiveData, dirPath, compressionLevel); return archiveData; } @@ -422,7 +422,7 @@ static la_ssize_t archiveReadVectorCallback(struct archive *a, void* client_data return len; } -static void unarchiveToDir(const std::string& archivePath, const std::vector* archiveData, const std::string& dirPath) { +static void unarchiveToDirectory(const std::string& archivePath, const std::vector* archiveData, const std::string& dirPath) { // Based on minitar.c extract() in libarchive examples int r; @@ -510,12 +510,12 @@ static void unarchiveToDir(const std::string& archivePath, const std::vector& archiveData, const std::string& dirPath) { - unarchiveToDir("", &archiveData, dirPath); +void unarchiveToDirectory(const std::vector& archiveData, const std::string& dirPath) { + unarchiveToDirectory("", &archiveData, dirPath); } @@ -689,7 +689,7 @@ void openBrowser(const std::string& url) { } -void openDir(const std::string& path) { +void openDirectory(const std::string& path) { #if defined ARCH_LIN std::string command = "xdg-open \"" + path + "\""; (void) std::system(command.c_str());