FileDeleter

class FileDeleter(directory: Directory, messenger: (FileDeleter.MsgType, String) -> Unit)

This class provides ability to track the reference counts of a set of index files and delete them when their counts decreased to 0.

This class is NOT thread-safe, the user should make sure the thread-safety themselves

Constructors

Link copied to clipboard
constructor(directory: Directory, messenger: (FileDeleter.MsgType, String) -> Unit)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Types of messages this file deleter will broadcast REF: messages about reference FILE: messages about file

Link copied to clipboard
class RefCount

Tracks the reference count for a single index file:

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Decrease ref counts for all provided files, delete them if ref counts down to 0, even on exception. Throw first exception hit, if any

Link copied to clipboard
fun deleteFileIfNoRef(fileName: String)
Link copied to clipboard

delete only files that are unref'ed

Link copied to clipboard
fun exists(fileName: String): Boolean

return true only if file is touched and also has larger than 0 ref count

Link copied to clipboard
fun forceDelete(fileName: String)
Link copied to clipboard
fun getRefCount(fileName: String): Int

get ref count for a provided file, if the file is not yet recorded, this method will return 0

Link copied to clipboard
fun incRef(fileName: String)
Link copied to clipboard
fun initRefCount(fileName: String)

if the file is not yet recorded, this method will create a new RefCount object with count 0