Adds filter exclusion.

Some refactoring.
This commit is contained in:
Andrea Mazzoleni 2011-03-16 23:52:10 +01:00
parent c2d113685e
commit b9b8fd0bb8
24 changed files with 687 additions and 217 deletions

28
elem.h
View file

@ -48,6 +48,16 @@ typedef uint32_t block_off_t;
*/
typedef uint64_t data_off_t;
/**
* Filter for paths.
*/
struct snapraid_filter {
char pattern[PATH_MAX]; /**< Filter pattern. */
int is_path; /**< If the pattern is only for the complete path. */
int is_dir; /**< If the pattern is only for dir. */
tommy_node node; /**< Next node in the list. */
};
struct snapraid_file;
/**
@ -88,6 +98,22 @@ struct snapraid_disk {
tommy_array blockarr; /**< Block array of the disk. */
};
/**
* Allocates an exclusion.
*/
struct snapraid_filter* filter_alloc(const char* pattern);
/**
* Deallocates an exclusion.
*/
void filter_free(struct snapraid_filter* filter);
/**
* Checks if a path/name matches the pattern.
* Returns 0 if it matches.
*/
int filter_filter(struct snapraid_filter* filter, const char* path, const char* name, int is_dir);
/**
* Gets the relative position of a block inside the file.
*/
@ -105,7 +131,7 @@ unsigned block_file_size(struct snapraid_block* block, unsigned block_size);
struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, time_t mtime);
/**
* Deallocate a file.
* Deallocates a file.
*/
void file_free(struct snapraid_file* file);