Added some more unimplemented functions

This commit is contained in:
Alexei KADIR 2024-02-15 00:34:48 +01:00
parent 07e04889a5
commit 7d826ccb99
4 changed files with 36 additions and 1 deletions

View File

@ -64,3 +64,8 @@ bool backing_exists(const char* backing) {
return true;
}
uint64_t get_backing_creation_time(const char* backing) {
// A valid backing name is a number, corresponding to the timestamp of the backing disk creation
return strtoull(backing, NULL, 10);
}

View File

@ -26,6 +26,11 @@ bool backing_exists(const char* backing);
/// @return The list of backing disks. The caller is responsible for freeing the returned array and strings. This function can return NULL.
char** list_backings(void);
/// @brief Get the creation time of the specified backing disk.
/// @param backing The valid backing disk name.
/// @return The creation time of the specified backing disk. If the backing disk does not exist, this function returns 0.
uint64_t get_backing_creation_time(const char* backing);
/// @brief Finds the latest backing disk.
/// @return The latest backing disk. The caller is responsible for freeing the returned string. This function can return NULL.
char* find_latest_backing(void);

View File

@ -20,6 +20,12 @@ bool create_backed_disk(const char* disk, const char* backing);
/// @return true if the disk is packed, otherwise false.
bool pack_disk(const char* disk);
/// @brief Moves the backing file of a disk.
/// @param disk The path to the disk, which exists.
/// @param backing The path to the new backing file, which exists.
/// @return true if the backing file is moved, otherwise false.
bool move_backing_file(const char* disk, const char* backing);
/// @brief Gets the backing file of a disk.
/// @param disk The path to the disk, which exists.
/// @return The backing file of the disk. The caller is responsible for freeing the returned string. This function can return NULL.

View File

@ -26,6 +26,11 @@ bool entry_exists(const char* entry);
/// @return The list of entries. The caller is responsible for freeing the returned array and strings. This function can return NULL.
char** list_entries(void);
/// @brief Get the last access time of the specified entry.
/// @param entry The valid entry name, which must exist.
/// @return The last access time of the specified entry. If the entry does not exist, this function returns 0.
uint64_t get_entry_last_access(const char* entry);
/// @brief Finds the oldest entry (based on last access time).
/// @return The oldest entry. The caller is responsible for freeing the returned string. This function can return NULL.
char* find_oldest_entry(void);
@ -39,3 +44,17 @@ bool create_entry(const char* entry);
/// @param entry The valid entry name.
/// @return true if the entry was deleted, otherwise false.
bool delete_entry(const char* entry);
/// @brief Updates the last access time of the specified entry.
/// @param entry The valid entry name, which must exist.
/// @return true if the last access time was updated, otherwise false.
bool update_entry_last_access(const char* entry);
/// @brief Returns the available space in the entries directory.
/// @return The available space in the entries directory. If the entries directory does not exist, this function returns 0.
uint64_t get_available_space(void);
/// @brief Reserves the specified space in the entries directory, by deleting the oldest entries.
/// @param space The space to reserve, in bytes.
/// @return true if the space was fully reserved, otherwise false.
bool reserve_space(uint64_t space);