Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions binaryninjaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions binaryninjaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@ namespace BinaryNinja {
void SetBundledPluginDirectory(const std::string& path);
std::string GetUserDirectory();

std::string GetSystemCacheDirectory();

std::string GetSettingsFileName();
std::string GetRepositoriesDirectory();
std::string GetInstallDirectory();
Expand Down
1 change: 1 addition & 0 deletions binaryninjacore.h
Original file line number Diff line number Diff line change
Expand Up @@ -7530,6 +7530,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);
Expand Down
13 changes: 13 additions & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,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):
"""
Expand Down
Loading