Class FileCache
- java.lang.Object
-
- ghidra.formats.gfilesystem.FileCache
-
public class FileCache extends java.lang.ObjectFile caching implementation.Caches files based on a hash of the contents of the file.
Files are retrieved using the hash string.
Cached files are stored in a file with a name that is the hex encoded value of the hash.
Cached files are obfuscated/de-obfuscated when written/read to/from disk. SeeObfuscatedFileByteProvider,ObfuscatedInputStream,ObfuscatedOutputStream.
Cached files are organized into a nested directory structure to prevent overwhelming a single directory with thousands of files.Nested directory structure is based on the file's name:
File: AABBCCDDEEFF... → AA/AABBCCDDEEFF...
Cache size is not bounded.
Cache maintenance is done during startup if interval since last maintenance has been exceeded.
Files are not removed from the cache after being added, except during startup maintenance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileCache.FileCacheEntryRepresents a cached file.classFileCache.FileCacheEntryBuilderAllows creatingfile cache entriesat the caller's convenience.
-
Field Summary
Fields Modifier and Type Field Description static intMAX_INMEM_FILESIZEMax size of a file that will be kept inmemCache(2Mb)static intMD5_HEXSTR_LEN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidperformCacheMaintOnOldDirIfNeeded(java.io.File oldCacheDir)Deprecated, for removal: This API element is subject to removal in a future version.Marked as deprecated to ensure this is removed in a few versions after most user's old-style cache dirs have been cleaned up.voidpurge()Deletes all stored files from this file cache that are under a "NN" two hex digit nesting dir.java.lang.StringtoString()
-
-
-
Field Detail
-
MAX_INMEM_FILESIZE
public static final int MAX_INMEM_FILESIZE
Max size of a file that will be kept inmemCache(2Mb)- See Also:
- Constant Field Values
-
MD5_HEXSTR_LEN
public static final int MD5_HEXSTR_LEN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileCache
public FileCache(java.io.File cacheDir) throws java.io.IOExceptionCreates a newFileCacheinstance where files are stored under the specifiedcacheDir- Parameters:
cacheDir- where to store the files- Throws:
java.io.IOException- if there was a problem creating subdirectories under cacheDir or when pruning expired files.
-
-
Method Detail
-
performCacheMaintOnOldDirIfNeeded
@Deprecated(forRemoval=true, since="10.1") public static void performCacheMaintOnOldDirIfNeeded(java.io.File oldCacheDir)Deprecated, for removal: This API element is subject to removal in a future version.Marked as deprecated to ensure this is removed in a few versions after most user's old-style cache dirs have been cleaned up.Backwards compatible with previous cache directories to age off the files located therein.- Parameters:
oldCacheDir- the old 2-level cache directory
-
purge
public void purge()
Deletes all stored files from this file cache that are under a "NN" two hex digit nesting dir.Will cause other processes which are accessing or updating the cache to error.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-