fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
index.h
Go to the documentation of this file.
1
3#ifndef FSAUTOPROC_INDEX_H
4#define FSAUTOPROC_INDEX_H
5
6#include <stdio.h>
7
8#include "fs.h"
9
12struct inode_s {
13 char* fp;
14 struct fsstat_s st;
15 struct inode_s* next;
16};
17
20#define INDEXBUCKETS 64
21
24struct index_s {
26 long size;
27};
28
33struct inode_s* indexfind(const struct index_s* idx, const char* fp);
34
41int indexwrite(struct index_s* idx, FILE* s);
42
49int indexread(struct index_s* idx, FILE* s);
50
56struct inode_s* indexput(struct index_s* idx, struct inode_s node);
57
60void indexfree(struct index_s* idx);
61
68struct inode_s** indexlist(const struct index_s* idx);
69
70#endif// FSAUTOPROC_INDEX_H
Filesystem walk and stat functions.
int indexread(struct index_s *idx, FILE *s)
Reads a file stream and deserializes the contents into a map of individual file nodes.
Definition index.c:67
struct inode_s ** indexlist(const struct index_s *idx)
Flattens the index map into an unsorted array of nodes. The list is dynamically allocated and must be...
Definition index.c:119
int indexwrite(struct index_s *idx, FILE *s)
Flattens the index map into a sorted array of nodes (by filepath). The list is then written to the fi...
Definition index.c:46
#define INDEXBUCKETS
The fixed number of buckets in the index map.
Definition index.h:20
struct inode_s * indexput(struct index_s *idx, struct inode_s node)
Copies the node and inserts it into the index mapping.
Definition index.c:95
struct inode_s * indexfind(const struct index_s *idx, const char *fp)
Searches the index for a node with a matching filepath.
Definition index.c:26
void indexfree(struct index_s *idx)
Frees all nodes in the index map.
Definition index.c:115
Stat structure for storing the last modified time and file size.
Definition fs.h:33
Index map structure for storing file nodes.
Definition index.h:24
long size
Number of sum nodes in the index.
Definition index.h:26
struct inode_s * buckets[INDEXBUCKETS]
Array of index buckets.
Definition index.h:25
Individual file node in the index map.
Definition index.h:12
struct fsstat_s st
File stat info structure.
Definition index.h:14
struct inode_s * next
Next node in the index map.
Definition index.h:15
char * fp
File path (string duplicated)
Definition index.h:13