docs(api): migrate consumers to CamelCase
All checks were successful
Linux unit tests / unit-tests (push) Successful in 30s
All checks were successful
Linux unit tests / unit-tests (push) Successful in 30s
This commit is contained in:
26
README.md
26
README.md
@@ -42,23 +42,23 @@ target_link_libraries(your_target PRIVATE iZo::izo)
|
||||
Include individual feature headers or the complete API:
|
||||
|
||||
```cpp
|
||||
#include <izo/izo.hpp>
|
||||
#include <izo/iZo.hpp>
|
||||
|
||||
izo::dialog_options options;
|
||||
izo::DialogOptions options;
|
||||
options.title = "Choose an image";
|
||||
options.filters = {{"Images", {"*.png", "*.jpg"}}};
|
||||
|
||||
if (auto selection = izo::open_file(options)) {
|
||||
izo::reveal_in_file_manager(selection.paths.front());
|
||||
if (auto selection = izo::OpenFile(options)) {
|
||||
izo::RevealInFileManager(selection.paths.front());
|
||||
}
|
||||
|
||||
auto config = izo::get_known_path(izo::known_path::config);
|
||||
auto config = izo::GetKnownPath(izo::KnownPath::Config);
|
||||
|
||||
izo::process_options process;
|
||||
izo::ProcessOptions process;
|
||||
process.executable = "tool";
|
||||
process.arguments = {"--input", "asset.png"};
|
||||
if (auto launched = izo::launch_process(process)) {
|
||||
// launched.process_id identifies the new process.
|
||||
if (auto launched = izo::LaunchProcess(process)) {
|
||||
// launched.processId identifies the new process.
|
||||
}
|
||||
```
|
||||
|
||||
@@ -66,16 +66,16 @@ Resource-owning APIs are move-only and clean themselves up:
|
||||
|
||||
```cpp
|
||||
std::string error;
|
||||
auto library = izo::load_dynamic_library("plugin.dll", &error);
|
||||
auto library = izo::LoadDynamicLibrary("plugin.dll", &error);
|
||||
if (library) {
|
||||
void* entry = library.symbol("initialize_plugin", &error);
|
||||
void* entry = library.Symbol("initialize_plugin", &error);
|
||||
}
|
||||
|
||||
auto watcher = izo::watch_directory(
|
||||
auto watcher = izo::WatchDirectory(
|
||||
{{"assets"}, true},
|
||||
[](const izo::file_event& event) {
|
||||
[](const izo::FileEvent& event) {
|
||||
// Handle added, removed, modified, or renamed files.
|
||||
// Rename events provide the old path in event.previous_path.
|
||||
// Rename events provide the old path in event.previousPath.
|
||||
},
|
||||
&error);
|
||||
```
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include <izo/dialogs.hpp>
|
||||
#include <izo/Dialogs.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
izo::dialog_options options;
|
||||
izo::DialogOptions options;
|
||||
options.title = "Choose an image";
|
||||
options.filters = {
|
||||
{"Images", {"*.png", "*.jpg", "*.jpeg"}},
|
||||
{"All files", {"*"}},
|
||||
};
|
||||
|
||||
const auto result = izo::open_file(options);
|
||||
const auto result = izo::OpenFile(options);
|
||||
if (result) {
|
||||
std::cout << result.paths.front().string() << '\n';
|
||||
return 0;
|
||||
}
|
||||
if (result.status == izo::dialog_status::error) {
|
||||
std::cerr << result.error_message << '\n';
|
||||
if (result.status == izo::DialogStatus::Error) {
|
||||
std::cerr << result.errorMessage << '\n';
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/directory_watcher.hpp>
|
||||
#include <izo/DirectoryWatcher.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@@ -9,22 +9,22 @@
|
||||
|
||||
int main() {
|
||||
std::string error;
|
||||
CHECK(!izo::watch_directory({"/izo/missing", false}, [](const auto&) {}, &error));
|
||||
CHECK(!izo::WatchDirectory({"/izo/missing", false}, [](const auto&) {}, &error));
|
||||
CHECK(!error.empty());
|
||||
error.clear();
|
||||
|
||||
const auto directory = test_directory("watcher");
|
||||
CHECK(!izo::watch_directory({directory, false}, {}, &error));
|
||||
CHECK(!izo::WatchDirectory({directory, false}, {}, &error));
|
||||
CHECK(!error.empty());
|
||||
error.clear();
|
||||
CHECK(!izo::watch_directory({directory, false, std::chrono::milliseconds(0)},
|
||||
CHECK(!izo::WatchDirectory({directory, false, std::chrono::milliseconds(0)},
|
||||
[](const auto&) {}, &error));
|
||||
|
||||
std::mutex mutex;
|
||||
std::vector<izo::file_event> events;
|
||||
auto watcher = izo::watch_directory(
|
||||
std::vector<izo::FileEvent> events;
|
||||
auto watcher = izo::WatchDirectory(
|
||||
{directory, true, std::chrono::milliseconds(10)},
|
||||
[&](const izo::file_event& event) {
|
||||
[&](const izo::FileEvent& event) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
events.push_back(event);
|
||||
}, &error);
|
||||
@@ -37,7 +37,7 @@ int main() {
|
||||
CHECK(wait_until([&] {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return std::any_of(events.begin(), events.end(), [&](const auto& event) {
|
||||
return event.change == izo::file_change::added && event.path == original;
|
||||
return event.change == izo::FileChange::Added && event.path == original;
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -45,7 +45,7 @@ int main() {
|
||||
CHECK(wait_until([&] {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return std::any_of(events.begin(), events.end(), [&](const auto& event) {
|
||||
return event.change == izo::file_change::modified && event.path == original;
|
||||
return event.change == izo::FileChange::Modified && event.path == original;
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -53,8 +53,8 @@ int main() {
|
||||
CHECK(wait_until([&] {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return std::any_of(events.begin(), events.end(), [&](const auto& event) {
|
||||
return event.change == izo::file_change::renamed && event.path == renamed &&
|
||||
event.previous_path == original;
|
||||
return event.change == izo::FileChange::Renamed && event.path == renamed &&
|
||||
event.previousPath == original;
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -62,10 +62,10 @@ int main() {
|
||||
CHECK(wait_until([&] {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return std::any_of(events.begin(), events.end(), [&](const auto& event) {
|
||||
return event.change == izo::file_change::removed && event.path == renamed;
|
||||
return event.change == izo::FileChange::Removed && event.path == renamed;
|
||||
});
|
||||
}));
|
||||
watcher.stop();
|
||||
watcher.Stop();
|
||||
CHECK(!watcher);
|
||||
std::filesystem::remove_all(directory);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/dynamic_library.hpp>
|
||||
#include <izo/DynamicLibrary.hpp>
|
||||
|
||||
#include <utility>
|
||||
|
||||
int main() {
|
||||
std::string error;
|
||||
auto missing = izo::load_dynamic_library("/izo/does/not/exist.so", &error);
|
||||
auto missing = izo::LoadDynamicLibrary("/izo/does/not/exist.so", &error);
|
||||
CHECK(!missing);
|
||||
CHECK(!error.empty());
|
||||
|
||||
error.clear();
|
||||
auto library = izo::load_dynamic_library("libc.so.6", &error);
|
||||
auto library = izo::LoadDynamicLibrary("libc.so.6", &error);
|
||||
CHECK(library);
|
||||
CHECK(library.symbol("getpid", &error) != nullptr);
|
||||
CHECK(library.Symbol("getpid", &error) != nullptr);
|
||||
error.clear();
|
||||
CHECK(library.symbol("izo_missing_symbol", &error) == nullptr);
|
||||
CHECK(library.Symbol("izo_missing_symbol", &error) == nullptr);
|
||||
CHECK(!error.empty());
|
||||
|
||||
auto moved = std::move(library);
|
||||
CHECK(!library);
|
||||
CHECK(moved);
|
||||
moved.reset();
|
||||
moved.Reset();
|
||||
CHECK(!moved);
|
||||
error.clear();
|
||||
CHECK(moved.symbol("getpid", &error) == nullptr);
|
||||
CHECK(moved.Symbol("getpid", &error) == nullptr);
|
||||
CHECK(!error.empty());
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/environment.hpp>
|
||||
#include <izo/paths.hpp>
|
||||
#include <izo/Environment.hpp>
|
||||
#include <izo/Paths.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
int main() {
|
||||
std::string error;
|
||||
CHECK(izo::set_environment_variable("IZO_TEST_VALUE", "hello-utf8-å", &error));
|
||||
CHECK(izo::get_environment_variable("IZO_TEST_VALUE") == "hello-utf8-å");
|
||||
CHECK(izo::set_environment_variable("IZO_TEST_VALUE", "", &error));
|
||||
CHECK(izo::get_environment_variable("IZO_TEST_VALUE") == "");
|
||||
CHECK(izo::unset_environment_variable("IZO_TEST_VALUE", &error));
|
||||
CHECK(!izo::get_environment_variable("IZO_TEST_VALUE"));
|
||||
CHECK(izo::SetEnvVar("IZO_TEST_VALUE", "hello-utf8-å", &error));
|
||||
CHECK(izo::GetEnvVar("IZO_TEST_VALUE") == "hello-utf8-å");
|
||||
CHECK(izo::SetEnvVar("IZO_TEST_VALUE", "", &error));
|
||||
CHECK(izo::GetEnvVar("IZO_TEST_VALUE") == "");
|
||||
CHECK(izo::UnsetEnvVar("IZO_TEST_VALUE", &error));
|
||||
CHECK(!izo::GetEnvVar("IZO_TEST_VALUE"));
|
||||
|
||||
const auto root = test_directory("paths");
|
||||
CHECK(izo::set_environment_variable("HOME", root.string(), &error));
|
||||
CHECK(izo::unset_environment_variable("XDG_DATA_HOME", &error));
|
||||
CHECK(izo::unset_environment_variable("XDG_CONFIG_HOME", &error));
|
||||
CHECK(izo::unset_environment_variable("XDG_CACHE_HOME", &error));
|
||||
CHECK(izo::unset_environment_variable("TMPDIR", &error));
|
||||
CHECK(izo::SetEnvVar("HOME", root.string(), &error));
|
||||
CHECK(izo::UnsetEnvVar("XDG_DATA_HOME", &error));
|
||||
CHECK(izo::UnsetEnvVar("XDG_CONFIG_HOME", &error));
|
||||
CHECK(izo::UnsetEnvVar("XDG_CACHE_HOME", &error));
|
||||
CHECK(izo::UnsetEnvVar("TMPDIR", &error));
|
||||
|
||||
CHECK(izo::get_known_path(izo::known_path::app_data) == root / ".local/share");
|
||||
CHECK(izo::get_known_path(izo::known_path::local_app_data) == root / ".local/share");
|
||||
CHECK(izo::get_known_path(izo::known_path::config) == root / ".config");
|
||||
CHECK(izo::get_known_path(izo::known_path::cache) == root / ".cache");
|
||||
CHECK(izo::get_known_path(izo::known_path::documents) == root / "Documents");
|
||||
CHECK(izo::get_known_path(izo::known_path::downloads) == root / "Downloads");
|
||||
CHECK(izo::get_known_path(izo::known_path::desktop) == root / "Desktop");
|
||||
CHECK(izo::get_known_path(izo::known_path::temporary) == "/tmp");
|
||||
CHECK(!izo::get_known_path(izo::known_path::executable_directory, &error).empty());
|
||||
CHECK(izo::get_known_path(izo::known_path::current_directory, &error) ==
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::AppData) == root / ".local/share");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::LocalAppData) == root / ".local/share");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Config) == root / ".config");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Cache) == root / ".cache");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Documents) == root / "Documents");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Downloads) == root / "Downloads");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Desktop) == root / "Desktop");
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Temporary) == "/tmp");
|
||||
CHECK(!izo::GetKnownPath(izo::KnownPath::ExecutableDirectory, &error).empty());
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::CurrentDirectory, &error) ==
|
||||
std::filesystem::current_path());
|
||||
|
||||
CHECK(izo::set_environment_variable("XDG_CONFIG_HOME", (root / "custom-config").string(), &error));
|
||||
CHECK(izo::get_known_path(izo::known_path::config) == root / "custom-config");
|
||||
CHECK(izo::SetEnvVar("XDG_CONFIG_HOME", (root / "custom-config").string(), &error));
|
||||
CHECK(izo::GetKnownPath(izo::KnownPath::Config) == root / "custom-config");
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/clipboard.hpp>
|
||||
#include <izo/dialogs.hpp>
|
||||
#include <izo/environment.hpp>
|
||||
#include <izo/message_box.hpp>
|
||||
#include <izo/Clipboard.hpp>
|
||||
#include <izo/Dialogs.hpp>
|
||||
#include <izo/Environment.hpp>
|
||||
#include <izo/MessageBox.hpp>
|
||||
|
||||
int main() {
|
||||
std::string error;
|
||||
CHECK(izo::set_environment_variable("PATH", "", &error));
|
||||
CHECK(izo::SetEnvVar("PATH", "", &error));
|
||||
|
||||
auto dialog = izo::open_file();
|
||||
CHECK(dialog.status == izo::dialog_status::error);
|
||||
CHECK(!dialog.error_message.empty());
|
||||
dialog = izo::save_file();
|
||||
CHECK(dialog.status == izo::dialog_status::error);
|
||||
dialog = izo::pick_folder();
|
||||
CHECK(dialog.status == izo::dialog_status::error);
|
||||
auto dialog = izo::OpenFile();
|
||||
CHECK(dialog.status == izo::DialogStatus::Error);
|
||||
CHECK(!dialog.errorMessage.empty());
|
||||
dialog = izo::SaveFile();
|
||||
CHECK(dialog.status == izo::DialogStatus::Error);
|
||||
dialog = izo::PickFolder();
|
||||
CHECK(dialog.status == izo::DialogStatus::Error);
|
||||
|
||||
error.clear();
|
||||
CHECK(!izo::open_path("/tmp", &error));
|
||||
CHECK(!izo::OpenPath("/tmp", &error));
|
||||
CHECK(!error.empty());
|
||||
error.clear();
|
||||
CHECK(!izo::reveal_in_file_manager("/tmp/file", &error));
|
||||
CHECK(!izo::RevealInFileManager("/tmp/file", &error));
|
||||
CHECK(!error.empty());
|
||||
|
||||
error.clear();
|
||||
CHECK(izo::show_message_box({"title", "message"}, &error) == izo::message_response::error);
|
||||
CHECK(izo::ShowMessageBox({"title", "message"}, &error) == izo::MessageResponse::Error);
|
||||
CHECK(!error.empty());
|
||||
error.clear();
|
||||
CHECK(!izo::set_clipboard_text({}, &error));
|
||||
CHECK(!izo::SetClipboardText({}, &error));
|
||||
CHECK(!error.empty());
|
||||
error.clear();
|
||||
CHECK(!izo::get_clipboard_text(&error));
|
||||
CHECK(!izo::GetClipboardText(&error));
|
||||
CHECK(!error.empty());
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/process.hpp>
|
||||
#include <izo/Process.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
int main() {
|
||||
std::string marker;
|
||||
auto result = izo::launch_process({});
|
||||
auto result = izo::LaunchProcess({});
|
||||
CHECK(!result);
|
||||
CHECK(!result.error_message.empty());
|
||||
CHECK(!result.errorMessage.empty());
|
||||
|
||||
result = izo::launch_process({"/izo/missing-executable", {}, {}, false});
|
||||
result = izo::LaunchProcess({"/izo/missing-executable", {}, {}, false});
|
||||
CHECK(!result);
|
||||
CHECK(!result.error_message.empty());
|
||||
CHECK(!result.errorMessage.empty());
|
||||
|
||||
const auto directory = test_directory("process");
|
||||
result = izo::launch_process({"/bin/sh", {"-c", "printf launched > marker.txt"}, directory, false});
|
||||
result = izo::LaunchProcess({"/bin/sh", {"-c", "printf launched > marker.txt"}, directory, false});
|
||||
CHECK(result);
|
||||
CHECK(result.process_id > 0);
|
||||
CHECK(result.processId > 0);
|
||||
CHECK(wait_until([&] { return std::filesystem::exists(directory / "marker.txt"); }));
|
||||
std::ifstream(directory / "marker.txt") >> marker;
|
||||
CHECK(marker == "launched");
|
||||
|
||||
result = izo::launch_process({"/bin/true", {}, directory / "missing", false});
|
||||
result = izo::LaunchProcess({"/bin/true", {}, directory / "missing", false});
|
||||
CHECK(!result);
|
||||
CHECK(!result.error_message.empty());
|
||||
CHECK(!result.errorMessage.empty());
|
||||
std::filesystem::remove_all(directory);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#include "test_support.hpp"
|
||||
|
||||
#include <izo/debug.hpp>
|
||||
#include <izo/system.hpp>
|
||||
#include <izo/time.hpp>
|
||||
#include <izo/Debug.hpp>
|
||||
#include <izo/System.hpp>
|
||||
#include <izo/Time.hpp>
|
||||
|
||||
int main() {
|
||||
const auto info = izo::get_system_info();
|
||||
CHECK(info.logical_cpu_count > 0);
|
||||
CHECK(info.total_memory_bytes > 0);
|
||||
CHECK(info.available_memory_bytes <= info.total_memory_bytes);
|
||||
CHECK(info.os_name == "Linux");
|
||||
CHECK(!info.os_version.empty());
|
||||
const auto info = izo::GetSystemInfo();
|
||||
CHECK(info.logicalCpuCount > 0);
|
||||
CHECK(info.totalMemoryBytes > 0);
|
||||
CHECK(info.availableMemoryBytes <= info.totalMemoryBytes);
|
||||
CHECK(info.osName == "Linux");
|
||||
CHECK(!info.osVersion.empty());
|
||||
|
||||
const auto before = izo::monotonic_now();
|
||||
izo::sleep_for(std::chrono::milliseconds(5));
|
||||
CHECK(izo::monotonic_now() > before);
|
||||
izo::sleep_for(std::chrono::nanoseconds(-1));
|
||||
const auto before = izo::MonotonicNow();
|
||||
izo::SleepFor(std::chrono::milliseconds(5));
|
||||
CHECK(izo::MonotonicNow() > before);
|
||||
izo::SleepFor(std::chrono::nanoseconds(-1));
|
||||
|
||||
(void)izo::is_debugger_attached();
|
||||
izo::debug_output("iZo debug output test\n");
|
||||
izo::install_crash_handler(nullptr);
|
||||
(void)izo::IsDebuggerAttached();
|
||||
izo::DebugOutput("iZo debug output test\n");
|
||||
izo::InstallCrashHandler(nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user