Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : /// Enable globally cache/memoization. One can also leverage this function
4 : /// by setting the environment variable `DYLDSC_ENABLE_CACHE` to `1`
5 : ///
6 : /// By default, LIEF will use the directory specified by the environment
7 : /// variable `DYLDSC_CACHE_DIR` as its cache-root directory:
8 : ///
9 : /// ```bash
10 : /// DYLDSC_ENABLE_CACHE=1 DYLDSC_CACHE_DIR=/tmp/my_dir ./my-program
11 : /// ```
12 : ///
13 : /// Otherwise, if `DYLDSC_CACHE_DIR` is not set, LIEF will use the following
14 : /// directory (in this priority):
15 : ///
16 : /// 1. System or user cache directory
17 : /// - macOS: `DARWIN_USER_TEMP_DIR` / `DARWIN_USER_CACHE_DIR` + `/dyld_shared_cache`
18 : /// - Linux: `${XDG_CACHE_HOME}/dyld_shared_cache`
19 : /// - Windows: `%LOCALAPPDATA%\dyld_shared_cache`
20 : /// 2. Home directory
21 : /// - macOS/Linux: `$HOME/.dyld_shared_cache`
22 : /// - Windows: `%USERPROFILE%\.dyld_shared_cache`
23 : ///
24 : /// See [`crate::dsc::DyldSharedCache::enable_caching`] for a finer granularity
25 0 : pub fn enable_cache() -> bool {
26 0 : ffi::dsc_enable_cache()
27 0 : }
28 :
29 : /// Same behavior as [`enable_cache`] but with a user-provided cache directory
30 0 : pub fn enable_cache_from_dir(target_dir: &str) -> bool {
31 0 : ffi::dsc_enable_cache_from_dir(target_dir)
32 0 : }
|