Mercurial > hg > toybox
comparison lib/lib.h @ 580:4877cff01b25
dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 20 May 2012 15:00:19 -0500 |
parents | 44abf4d901f3 |
children | 1dcd7994abea |
comparison
equal
deleted
inserted
replaced
579:6a7d64f51b1b | 580:4877cff01b25 |
---|---|
46 // dirtree.c | 46 // dirtree.c |
47 | 47 |
48 // Values returnable from callback function (bitfield, or them together) | 48 // Values returnable from callback function (bitfield, or them together) |
49 // Default with no callback is 0 | 49 // Default with no callback is 0 |
50 | 50 |
51 // Do not add this node to the tree | 51 // Add this node to the tree |
52 #define DIRTREE_NOSAVE 1 | 52 #define DIRTREE_SAVE 1 |
53 // Do not recurse into children | 53 // Recurse into children |
54 #define DIRTREE_NORECURSE 2 | 54 #define DIRTREE_RECURSE 2 |
55 // Call again after handling all children (Directories only. Sets linklen = -1) | 55 // Call again after handling all children of this directory |
56 // (Ignored for non-directories, sets linklen = -1 before second call.) | |
56 #define DIRTREE_COMEAGAIN 4 | 57 #define DIRTREE_COMEAGAIN 4 |
57 // Follow symlinks to directories | 58 // Follow symlinks to directories |
58 #define DIRTREE_SYMFOLLOW 8 | 59 #define DIRTREE_SYMFOLLOW 8 |
59 // Abort recursive dirtree. (Forces NOSAVE and NORECURSE on this entry.) | 60 // Don't look at any more files in this directory. |
60 #define DIRTREE_ABORT (256|DIRTREE_NOSAVE|DIRTREE_NORECURSE) | 61 #define DIRTREE_ABORT 256 |
61 | 62 |
62 #define DIRTREE_ABORTVAL ((struct dirtree *)1) | 63 #define DIRTREE_ABORTVAL ((struct dirtree *)1) |
63 | 64 |
64 struct dirtree { | 65 struct dirtree { |
65 struct dirtree *next, *parent, *child; | 66 struct dirtree *next, *parent, *child; |
70 char name[]; | 71 char name[]; |
71 }; | 72 }; |
72 | 73 |
73 struct dirtree *dirtree_add_node(int dirfd, char *name); | 74 struct dirtree *dirtree_add_node(int dirfd, char *name); |
74 char *dirtree_path(struct dirtree *node, int *plen); | 75 char *dirtree_path(struct dirtree *node, int *plen); |
75 int dirtree_isdotdot(struct dirtree *catch); | 76 int dirtree_notdotdot(struct dirtree *catch); |
76 struct dirtree *handle_callback(struct dirtree *new, | 77 struct dirtree *handle_callback(struct dirtree *new, |
77 int (*callback)(struct dirtree *node)); | 78 int (*callback)(struct dirtree *node)); |
78 void dirtree_recurse(struct dirtree *node, | 79 void dirtree_recurse(struct dirtree *node, |
79 int (*callback)(struct dirtree *node)); | 80 int (*callback)(struct dirtree *node)); |
80 struct dirtree *dirtree_read(char *path, int (*callback)(struct dirtree *node)); | 81 struct dirtree *dirtree_read(char *path, int (*callback)(struct dirtree *node)); |