2024-02-19 16:01:53 +01:00
# pragma once
# include "utils.h"
# define CONTAINER_IDENTIFIER_MAX_LENGTH 64
2024-02-19 20:03:30 +01:00
/// @brief Checks whether the given string is a valid container identifier. If the string is not a valid container identifier, the call will return a failure result with an error message.
/// @param container The string to check.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t check_container_identifier ( const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Checks whether the given container exists. If the container does not exist, the call will return a failure result with an error message.
/// @param container The container to check.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t check_container_exists ( const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Gets the container pool path.
/// @param _path The string pointer to store the resulting path in. The caller is responsible for freeing the string.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t get_container_pool_path ( char * * _path ) ;
2024-02-19 20:03:30 +01:00
/// @brief Gets the container path.
/// @param _path The string pointer to store the resulting path in. The caller is responsible for freeing the string.
/// @param container The container to get the path of.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t get_container_path ( char * * _path , const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Adds a root (empty) container to the pool, with the given size. If the container already exists, the call will return a failure result with an error message.
/// @param container The container to add.
/// @param size The size of the container to add, in bytes.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t add_root_container ( const char * container , uint64_t size ) ;
2024-02-19 20:03:30 +01:00
/// @brief Adds a backed container to the pool, with the given backing. If the container already exists, or the backing does not, the call will return a failure result with an error message.
/// @param container The container to add.
/// @param backing The backing to use for the container.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t add_backed_container ( const char * container , const char * backing ) ;
2024-02-19 20:03:30 +01:00
/// @brief Removes the given container from the pool. If the container does not exist, the call will return a failure result with an error message.
/// @param container The container to remove.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t remove_container ( const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Trims (removes unused space) the given container.
/// @param container The container to trim.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t trim_container ( const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Resets the given container to its initial state.
/// @param container The container to reset.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t reset_container ( const char * container ) ;
2024-02-19 20:03:30 +01:00
/// @brief Checks that the given file is a container. This function is used as a filter for listing containers.
/// @param file The file to check.
/// @return Whether the file is a container.
2024-02-19 16:01:53 +01:00
bool container_filter ( const char * file ) ;
2024-02-19 20:03:30 +01:00
/// @brief Lists the containers in the pool.
/// @param _containers The string pointer array to store the resulting array in. The caller is responsible for freeing the strings and the array.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t list_containers ( char * * * _containers ) ;