X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/84849cbd12159f7950a5ee35a36f5251a6d8bd3e..1f651677c857d752bc477c937a80a9a3ada5aff4:/trie.h diff --git a/trie.h b/trie.h index 40f6f75..ea24ef8 100644 --- a/trie.h +++ b/trie.h @@ -50,6 +50,17 @@ int triebuild_finish(triebuild *tb); void triebuild_free(triebuild *tb); /* ---------------------------------------------------------------------- + * Anomalous function which modifies a trie after it's memory-mapped. + */ + +/* + * Invent new fake atimes for each directory in the trie, by + * taking the maximum (latest) of the directory's previously + * stored atime and the atimes of everything below it. + */ +void trie_fake_dir_atimes(void *t); + +/* ---------------------------------------------------------------------- * Functions to query a trie given a pointer to the start of the * memory-mapped file. */ @@ -80,6 +91,11 @@ unsigned long trie_before(const void *t, const char *pathname); void trie_getpath(const void *t, unsigned long n, char *buf); /* + * Return the trie_file * for the nth entry in the trie. + */ +const struct trie_file *trie_getfile(const void *t, unsigned long n); + +/* * Return the total number of entries in the whole trie. */ unsigned long trie_count(const void *t); @@ -99,6 +115,7 @@ unsigned long trie_count(const void *t); typedef struct triewalk triewalk; triewalk *triewalk_new(const void *t); const struct trie_file *triewalk_next(triewalk *tw, char *buf); +void triewalk_rebase(triewalk *tw, const void *t); void triewalk_free(triewalk *tw); /* ---------------------------------------------------------------------- @@ -107,3 +124,19 @@ void triewalk_free(triewalk *tw); */ void trie_set_index_offset(void *t, off_t ptr); off_t trie_get_index_offset(const void *t); + +/* ---------------------------------------------------------------------- + * Utility functions not directly involved with the trie. + */ + +/* + * Given a pathname in a buffer, adjust the pathname in place so + * that it points at a string which, when passed to trie_before, + * will reliably return the index of the thing that comes after + * that pathname and all its descendants. Usually this is done by + * suffixing ^A (since foo^A is guaranteeably the first thing that + * sorts after foo and foo/stuff); however, if the pathname + * actually ends in a path separator (e.g. if it's just "/"), that + * must be stripped off first. + */ +void make_successor(char *pathbuf);