diff options
| author | Alexander Khosrowshahi <alexk@vector35.com> | 2025-07-09 12:05:31 -0400 |
|---|---|---|
| committer | Alexander Khosrowshahi <alexk@vector35.com> | 2025-07-09 12:05:31 -0400 |
| commit | beda6059f236f08d7179b7346655d19aaa47dd26 (patch) | |
| tree | 38d2cb086bc6bea4c2ab608628cd636303297d3f | |
| parent | 44e415514493ec30bb4066e8d2224be032ee8308 (diff) | |
Add get_system_cache_directory and GetSystemCacheDirectory to API
| -rw-r--r-- | binaryninjaapi.cpp | 11 | ||||
| -rw-r--r-- | binaryninjaapi.h | 6 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | python/__init__.py | 13 |
4 files changed, 31 insertions, 0 deletions
diff --git a/binaryninjaapi.cpp b/binaryninjaapi.cpp index f526320a..c35e28c8 100644 --- a/binaryninjaapi.cpp +++ b/binaryninjaapi.cpp @@ -95,6 +95,17 @@ string BinaryNinja::GetUserDirectory(void) } +string BinaryNinja::GetSystemCacheDirectory() +{ + char* dir = BNGetSystemCacheDirectory(); + if (!dir) + return string(); + std::string result(dir); + BNFreeString(dir); + return result; +} + + string BinaryNinja::GetSettingsFileName() { char* dir = BNGetSettingsFileName(); diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 82ab312f..3c96ab48 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1241,6 +1241,12 @@ namespace BinaryNinja { void SetBundledPluginDirectory(const std::string& path); std::string GetUserDirectory(); + /*! Get the Binary Ninja system cache directory + * + * @return std::string - Binary Ninja's cache directory on a given system + */ + std::string GetSystemCacheDirectory(); + std::string GetSettingsFileName(); std::string GetRepositoriesDirectory(); std::string GetInstallDirectory(); diff --git a/binaryninjacore.h b/binaryninjacore.h index db0250f1..472ad8e5 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -7558,6 +7558,7 @@ extern "C" BINARYNINJACOREAPI char** BNGetFilePathsInDirectory(const char* path, size_t* count); BINARYNINJACOREAPI char* BNAppendPath(const char* path, const char* part); BINARYNINJACOREAPI void BNFreePath(char* path); + BINARYNINJACOREAPI char* BNGetSystemCacheDirectory(); // Settings APIs BINARYNINJACOREAPI BNSettings* BNCreateSettings(const char* schemaId); diff --git a/python/__init__.py b/python/__init__.py index 59549b85..77c64fce 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -461,6 +461,19 @@ def connect_vscode_debugger(port=5678): debugpy.wait_for_client() execute_on_main_thread(lambda: debugpy.debug_this_thread()) +def get_system_cache_directory() -> Optional[str]: + """ + Returns Binary Ninja's system cache directory on the system. + + Supported default locations: + + - macOS: ~/Library/Caches/Binary Ninja + - Linux: $XDG_CACHE_HOME/Binary Ninja or ~/.cache/Binary Ninja + - Windows: %LOCALAPPDATA%/Binary Ninja/cache + + :return: Returns a string containing the system cache directory, or None on failure. + """ + return core.BNGetSystemCacheDirectory() class UIPluginInHeadlessError(Exception): """ |
