IDA C++ SDK 9.2
Loading...
Searching...
No Matches
dirtree.hpp
Go to the documentation of this file.
1
25
26#ifndef DIRTREE_HPP
27#define DIRTREE_HPP
28
29//------------------------------------------------------------------------
30typedef qvector<inode_t> inodevec_t; // sequence of inodes
31
36typedef qvector<diridx_t> dirvec_t; // sequence of directory indexes
37
40#define BAD_BLOB_IDX blob_idx_t(-1)
41
42// We use PACKED to save memory, without it we would spend 64 bits instead of
43// 8 bits to store a 1-bit value on ida64.
44#pragma pack(push, 1)
45
47struct PACKED direntry_t
48{
50 bool isdir;
51
52 static const uval_t BADIDX = uval_t(-1);
53 static const uval_t ROOTIDX = 0;
54
55 direntry_t(uval_t i=BADIDX, bool d=false) : idx(i), isdir(d) {}
56 bool valid() const { return idx != BADIDX; }
57
58 bool operator==(const direntry_t &r) const
59 {
60 return idx == r.idx && isdir == r.isdir;
61 }
62 bool operator!=(const direntry_t &r) const
63 {
64 return !(*this == r);
65 }
66 bool operator<(const direntry_t &r) const
67 {
68 if ( isdir != r.isdir )
69 return isdir; // any folder is lesser than any inode
70 return idx < r.idx;
71 }
72 bool operator>=(const direntry_t &r) const { return !(*this < r); }
73};
74#pragma pack(pop)
77
80enum
81{
89};
91
95static constexpr char DIRTREE_FOLDED_SEP = '\x1d'; // ASCII GS
96
101{
102 char from[2] = { DIRTREE_FOLDED_SEP, '\0' };
103 s->replace(from, "/");
104}
105
106//------------------------------------------------------------------------
110{
112 enum
113 {
114 DSF_INODE_EA = 0x01, // inode is EA, will be handled during segment moving
115 DSF_PRIVRANGE = 0x02, // inode is tid_t, structure or enum id, will be handled during segment moving
116 DSF_ORDERABLE = 0x04, // items in a folder are ordered by increasing inode # (unless explicitly reordered)
117 DSF_UNQ_NAMES = 0x08, // inode names are globally unique; this is implied for DSF_INODE_EA and DSF_PRIVRANGE
118 };
119 // netnode name to load/save directory tree
120 // If not specified the loading/storing operations are not supported
121 // and the undo functionality is not supported.
123
124 dirspec_t(const char *nm=nullptr, uint32 f=0) : dsf_flags(f), id(nm) {}
125
126 virtual ~dirspec_t() {}
127
134 virtual bool get_name(
135 qstring *out,
136 inode_t inode,
137 uint32 name_flags=DTN_FULL_NAME) = 0;
138
143 virtual inode_t get_inode(const char *dirpath, const char *name) = 0;
144
145 // print additional attributes of the entry. for example, is union? is mapped?
146 virtual qstring get_attrs(inode_t inode) const = 0;
147
152 virtual bool rename_inode(inode_t inode, const char *newname) = 0;
153
156 virtual void unlink_inode(inode_t inode) { qnotused(inode); }
157
158 bool is_orderable() const { return (dsf_flags & DSF_ORDERABLE) != 0; }
160 bool has_inode_ea() const { return (dsf_flags & DSF_INODE_EA) != 0; }
161};
162
163//------------------------------------------------------------------------
166{
168 size_t rank;
169 dirtree_cursor_t(diridx_t _parent=direntry_t::BADIDX, size_t _rank=size_t(-1))
170 : parent(_parent), rank(_rank) {}
171 bool valid() const { return parent != direntry_t::BADIDX || rank == 0; }
172 bool is_root_cursor() const { return parent == direntry_t::BADIDX && rank == 0; }
175 {
176 qswap(parent, r.parent);
177 qswap(rank, r.rank);
178 }
179
181 {
183 c.set_root_cursor();
184 return c;
185 }
186
188 {
189 if ( parent < r.parent ) return -1;
190 if ( parent > r.parent ) return 1;
191 if ( rank < r.rank ) return -1;
192 if ( rank > r.rank ) return 1;
193 return 0;
194 }
195};
198
199//-------------------------------------------------------------------------
201
202//------------------------------------------------------------------------
209
210//------------------------------------------------------------------------
226
228{
229 diridx_t parent; // parent directory
230 direntry_t entry; // entry inside the directory
231 dterr_t err; // error code for the item
232 int idx; // index into the vector of input vector
233 // (useful if parent/entry are wrong)
234};
237
238class dirtree_t;
239class dirtree_impl_t;
240struct segm_move_infos_t;
241
242//-------------------------------------------------------------------------
245{
253 virtual ssize_t visit(
254 const dirtree_cursor_t &c,
255 const direntry_t &de) = 0;
256};
257
258
260//------------------------------------------------------------------------
261// internal functions; use dirtree_t members instead
262#ifndef SWIG
263idaman dirtree_impl_t *ida_export create_dirtree(dirtree_t *dt, dirspec_t *ds);
264idaman void ida_export delete_dirtree(dirtree_impl_t *d);
265idaman bool ida_export load_dirtree(dirtree_impl_t *d);
266idaman bool ida_export save_dirtree(dirtree_impl_t *d);
267idaman void ida_export reset_dirtree(dirtree_impl_t *d);
268idaman const char *ida_export dirtree_errstr(dterr_t err);
269idaman bool ida_export dirtree_is_orderable(const dirtree_impl_t *d);
270idaman dterr_t ida_export dirtree_chdir(dirtree_impl_t *d, const char *path);
271idaman void ida_export dirtree_getcwd(qstring *out, const dirtree_impl_t *d);
272idaman void ida_export dirtree_resolve_path(direntry_t *de, const dirtree_impl_t *d, const char *path);
273idaman void ida_export dirtree_resolve_cursor(direntry_t *de, const dirtree_impl_t *d, const dirtree_cursor_t &cursor);
274idaman void ida_export dirtree_make_cursor(dirtree_cursor_t *cursor, const dirtree_impl_t *d, const char *path);
275idaman bool ida_export dirtree_get_entry_name(qstring *out, const dirtree_impl_t *d, const direntry_t &de, uint32 name_flags);
276idaman void ida_export dirtree_get_entry_attrs(qstring *out, const dirtree_impl_t *d, const direntry_t &de);
277idaman bool ida_export dirtree_is_dir_ordered(const dirtree_impl_t *d, diridx_t diridx);
278idaman dterr_t ida_export dirtree_set_natural_order(dirtree_impl_t *d, diridx_t diridx, bool enable);
279idaman ssize_t ida_export dirtree_get_dir_size(dirtree_impl_t *d, diridx_t diridx);
280idaman bool ida_export dirtree_findfirst(dirtree_impl_t *d, dirtree_iterator_t *ff, const char *pattern);
281idaman bool ida_export dirtree_findnext(dirtree_impl_t *d, dirtree_iterator_t *ff);
282idaman bool ida_export dirtree_get_abspath_by_cursor(qstring *out, const dirtree_impl_t *d, const dirtree_cursor_t &cursor, uint32 name_flags);
283idaman bool ida_export dirtree_get_abspath_by_relpath(qstring *out, const dirtree_impl_t *d, const char *relpath);
284idaman dterr_t ida_export dirtree_mkdir(dirtree_impl_t *d, const char *path);
285idaman dterr_t ida_export dirtree_rmdir(dirtree_impl_t *d, const char *path);
286idaman dterr_t ida_export dirtree_fold_common_prefix(dirtree_impl_t *d, const char *path, char sep);
287idaman dterr_t ida_export dirtree_link(dirtree_impl_t *d, const char *path, bool do_link);
288idaman dterr_t ida_export dirtree_link_inode(dirtree_impl_t *d, inode_t inode, bool do_link);
289idaman dterr_t ida_export dirtree_rename(dirtree_impl_t *d, const char *from, const char *to);
290idaman dterr_t ida_export dirtree_bulk_move(dirtree_impl_t *d, const dirtree_cursor_vec_t &items, const char *dstdir, int dst_rank, dirtree_cursor_vec_t *moved_items, dirtree_bulk_results_t *errs);
291idaman dterr_t ida_export dirtree_bulk_remove(dirtree_impl_t *d, const dirtree_cursor_vec_t &items, dirtree_bulk_results_t *errs);
292idaman ssize_t ida_export dirtree_get_rank(const dirtree_impl_t *d, diridx_t diridx, const direntry_t &de);
293idaman dterr_t ida_export dirtree_change_rank(dirtree_impl_t *d, const char *path, ssize_t rank_delta);
294idaman void ida_export dirtree_get_parent_cursor(dirtree_cursor_t *out, const dirtree_impl_t *d, const dirtree_cursor_t &cursor);
295idaman void ida_export notify_dirtree(dirtree_impl_t *d, bool added, inode_t inode);
296idaman const char *ida_export dirtree_get_id(const dirtree_impl_t *d);
297idaman void ida_export dirtree_set_id(dirtree_impl_t *d, const char *nm);
298idaman const char *ida_export dirtree_get_nodename(const dirtree_impl_t *d); // compat
299idaman void ida_export dirtree_set_nodename(dirtree_impl_t *d, const char *nm);// compat
300idaman ssize_t ida_export dirtree_traverse(dirtree_impl_t *d, dirtree_visitor_t &v);
301idaman dterr_t ida_export dirtree_find_entry(dirtree_cursor_t *out, const dirtree_t *_dt, const direntry_t &_de);
302idaman dirtree_t *ida_export dirtree_new_shadow_dirtree(dirtree_impl_t *d);
303idaman void ida_export dirtree_add_event_handler(dirtree_impl_t *d, class event_handler_t *h);
304idaman bool ida_export dirtree_remove_event_handler(dirtree_impl_t *d, class event_handler_t *h);
305#endif // SWIG
306
307
309
310//------------------------------------------------------------------------
315{
316 dirtree_impl_t *d;
317
318 friend struct dirtree_internal_t;
319
320public:
321 //lint -sem(dirtree_t::dirtree_t, custodial(1))
322 dirtree_t(dirspec_t *ds) { d = create_dirtree(this, ds); }
323 dirtree_t(dirtree_impl_t *di) { d = di; }
324 ~dirtree_t() { delete_dirtree(d); }
325
327 static const char *errstr(dterr_t err) { return dirtree_errstr(err); }
328
331 bool is_orderable() const { return dirtree_is_orderable(d); }
332
336 dterr_t chdir(const char *path) { return dirtree_chdir(d, path); }
337
341 {
342 qstring out;
343 dirtree_getcwd(&out, d);
344 return out;
345 }
346
353 qstring get_abspath(const dirtree_cursor_t &cursor, uint32 name_flags=DTN_FULL_NAME) const
354 {
355 qstring out;
356 dirtree_get_abspath_by_cursor(&out, d, cursor, name_flags);
357 return out;
358 }
359
365 qstring get_abspath(const char *relpath) const
366 {
367 qstring out;
368 dirtree_get_abspath_by_relpath(&out, d, relpath);
369 return out;
370 }
371
378 {
379 direntry_t de;
380 dirtree_resolve_cursor(&de, d, cursor);
381 return de;
382 }
383
389 dirtree_cursor_t make_cursor(const char *path) const
390 {
391 dirtree_cursor_t cursor;
392 dirtree_make_cursor(&cursor, d, path);
393 return cursor;
394 }
395
399 direntry_t resolve_path(const char *path) const
400 {
401 direntry_t de;
402 dirtree_resolve_path(&de, d, path);
403 return de;
404 }
405
406 static bool isdir(const direntry_t &de) { return de.valid() && de.isdir; }
407 static bool isfile(const direntry_t &de) { return de.valid() && !de.isdir; }
408
412 bool isdir(const char *path) const
413 {
414 direntry_t de = resolve_path(path);
415 return isdir(de);
416 }
417
421 bool isfile(const char *path) const
422 {
423 direntry_t de = resolve_path(path);
424 return isfile(de);
425 }
426
433 const direntry_t &de,
434 uint32 name_flags=DTN_FULL_NAME) const
435 {
436 qstring out;
437 dirtree_get_entry_name(&out, d, de, name_flags);
438 return out;
439 }
440
443 bool is_dir_ordered(diridx_t diridx) const { return dirtree_is_dir_ordered(d, diridx); }
444
453 dterr_t set_natural_order(diridx_t diridx, bool enable) const
454 {
455 return dirtree_set_natural_order(d, diridx, enable);
456 }
457
462 ssize_t get_dir_size(diridx_t diridx) const { return dirtree_get_dir_size(d, diridx); }
463
468 {
469 qstring out;
470 dirtree_get_entry_attrs(&out, d, de);
471 return out;
472 }
473
478 bool findfirst(dirtree_iterator_t *ff, const char *pattern) const
479 {
480 return dirtree_findfirst(d, ff, pattern);
481 }
482
487 {
488 return dirtree_findnext(d, ff);
489 }
490
494 dterr_t mkdir(const char *path) { return dirtree_mkdir(d, path); }
495
499 dterr_t rmdir(const char *path) { return dirtree_rmdir(d, path); }
500
504 dterr_t link(const char *path) { return dirtree_link(d, path, true); }
505
509 dterr_t unlink(const char *path) { return dirtree_link(d, path, false); }
510
514 dterr_t link(inode_t inode) { return dirtree_link_inode(d, inode, true); }
515
519 dterr_t unlink(inode_t inode) { return dirtree_link_inode(d, inode, false); }
520
526 dterr_t rename(const char *from, const char *to)
527 {
528 return dirtree_rename(d, from, to);
529 }
530
539 const char *path=nullptr,
540 char sep=DIRTREE_FOLDED_SEP)
541 {
542 return dirtree_fold_common_prefix(d, path, sep);
543 }
544
562 const dirtree_cursor_vec_t &items,
563 const char *dstdir,
564 ssize_t dst_rank=-1,
565 dirtree_cursor_vec_t *moved_items=nullptr,
566 dirtree_bulk_results_t *errs=nullptr)
567 {
568 return dirtree_bulk_move(d, items, dstdir, int(dst_rank), moved_items, errs);
569 }
570
576 const dirtree_cursor_vec_t &items,
577 dirtree_bulk_results_t *errs=nullptr)
578 {
579 return dirtree_bulk_remove(d, items, errs);
580 }
581
587 ssize_t get_rank(diridx_t diridx, const direntry_t &de) const
588 {
589 return dirtree_get_rank(d, diridx, de);
590 }
591
599 dterr_t change_rank(const char *path, ssize_t rank_delta)
600 {
601 return dirtree_change_rank(d, path, rank_delta);
602 }
603
608 {
609 dirtree_cursor_t parent;
610 dirtree_get_parent_cursor(&parent, d, cursor);
611 return parent;
612 }
613
620 bool load()
621 {
622 return load_dirtree(d);
623 }
624
628 bool save() const
629 {
630 return save_dirtree(d);
631 }
632
634 const char *get_id() const
635 {
636 return dirtree_get_id(d);
637 }
638
639 void set_id(const char *nm)
640 {
641 return dirtree_set_id(d, nm);
642 }
643
647 void notify_dirtree(bool added, inode_t inode)
648 {
649 ::notify_dirtree(d, added, inode);
650 }
651
661 {
662 return dirtree_traverse(d, v);
663 }
664
669 {
671 dirtree_find_entry(&c, this, de);
672 return c;
673 }
674
675};
676
691
692
693#endif // define DIRTREE_HPP
bool replace(const qchar *what, const qchar *with)
Replace all occurrences of 'what' with 'with'.
Definition pro.h:3412
Directory tree.
Definition dirtree.hpp:315
dterr_t link(inode_t inode)
Add an inode into the current directory.
Definition dirtree.hpp:514
bool isdir(const char *path) const
Is a directory?
Definition dirtree.hpp:412
dterr_t bulk_move(const dirtree_cursor_vec_t &items, const char *dstdir, ssize_t dst_rank=-1, dirtree_cursor_vec_t *moved_items=nullptr, dirtree_bulk_results_t *errs=nullptr)
Move many items to a directory.
Definition dirtree.hpp:561
bool isfile(const char *path) const
Is a file?
Definition dirtree.hpp:421
bool is_dir_ordered(diridx_t diridx) const
Is dir ordered?
Definition dirtree.hpp:443
direntry_t resolve_cursor(const dirtree_cursor_t &cursor) const
Resolve cursor.
Definition dirtree.hpp:377
const char * get_id() const
netnode name
Definition dirtree.hpp:634
dterr_t chdir(const char *path)
Change current directory.
Definition dirtree.hpp:336
dterr_t link(const char *path)
Add a file item into a directory.
Definition dirtree.hpp:504
dirtree_cursor_t make_cursor(const char *path) const
Make cursor from path.
Definition dirtree.hpp:389
~dirtree_t()
Definition dirtree.hpp:324
dterr_t bulk_remove(const dirtree_cursor_vec_t &items, dirtree_bulk_results_t *errs=nullptr)
Delete many items.
Definition dirtree.hpp:575
static bool isfile(const direntry_t &de)
Definition dirtree.hpp:407
dterr_t rename(const char *from, const char *to)
Rename a directory entry.
Definition dirtree.hpp:526
qstring get_abspath(const dirtree_cursor_t &cursor, uint32 name_flags=DTN_FULL_NAME) const
Get absolute path pointed by the cursor.
Definition dirtree.hpp:353
void set_id(const char *nm)
Definition dirtree.hpp:639
dirtree_t(dirspec_t *ds)
Definition dirtree.hpp:322
direntry_t resolve_path(const char *path) const
Resolve path.
Definition dirtree.hpp:399
dterr_t set_natural_order(diridx_t diridx, bool enable) const
Enable/disable natural inode order in a directory.
Definition dirtree.hpp:453
dterr_t change_rank(const char *path, ssize_t rank_delta)
Change ordering rank of an item.
Definition dirtree.hpp:599
friend struct dirtree_internal_t
Definition dirtree.hpp:318
ssize_t traverse(dirtree_visitor_t &v) const
Traverse dirtree, and be notified at each entry If the the visitor returns anything other than 0,...
Definition dirtree.hpp:660
dterr_t mkdir(const char *path)
Create a directory.
Definition dirtree.hpp:494
qstring get_entry_attrs(const direntry_t &de) const
Get entry attributes.
Definition dirtree.hpp:467
qstring get_entry_name(const direntry_t &de, uint32 name_flags=DTN_FULL_NAME) const
Get entry name.
Definition dirtree.hpp:432
bool is_orderable() const
Is dirtree orderable?
Definition dirtree.hpp:331
ssize_t get_rank(diridx_t diridx, const direntry_t &de) const
Get ordering rank of an item.
Definition dirtree.hpp:587
bool findfirst(dirtree_iterator_t *ff, const char *pattern) const
Start iterating over files in a directory.
Definition dirtree.hpp:478
dterr_t rmdir(const char *path)
Remove a directory.
Definition dirtree.hpp:499
dirtree_t(dirtree_impl_t *di)
Definition dirtree.hpp:323
qstring get_abspath(const char *relpath) const
Construct an absolute path from the specified relative path.
Definition dirtree.hpp:365
bool findnext(dirtree_iterator_t *ff) const
Continue iterating over files in a directory.
Definition dirtree.hpp:486
dirtree_cursor_t find_entry(const direntry_t &de) const
Find the cursor corresponding to an entry of a directory.
Definition dirtree.hpp:668
void notify_dirtree(bool added, inode_t inode)
Notify dirtree about a change of an inode.
Definition dirtree.hpp:647
dterr_t unlink(const char *path)
Remove a file item from a directory.
Definition dirtree.hpp:509
static bool isdir(const direntry_t &de)
Definition dirtree.hpp:406
ssize_t get_dir_size(diridx_t diridx) const
Get dir size.
Definition dirtree.hpp:462
bool load()
Load the tree structure from the netnode.
Definition dirtree.hpp:620
qstring getcwd() const
Get current directory.
Definition dirtree.hpp:340
static const char * errstr(dterr_t err)
Get textual representation of the error code.
Definition dirtree.hpp:327
dterr_t unlink(inode_t inode)
Remove an inode from the current directory.
Definition dirtree.hpp:519
dterr_t fold_common_prefix(const char *path=nullptr, char sep=DIRTREE_FOLDED_SEP)
Collapse single child folders into a single folder item The default separator (DIRTREE_FOLDED_SEP,...
Definition dirtree.hpp:538
dirtree_cursor_t get_parent_cursor(const dirtree_cursor_t &cursor) const
Get parent cursor.
Definition dirtree.hpp:607
bool save() const
Save the tree structure to the netnode.
Definition dirtree.hpp:628
Reimplementation of vector class from STL.
Definition pro.h:2262
dirtree_id_t
Built-in dirtree specializations:
Definition dirtree.hpp:679
@ DIRTREE_FUNCS
Definition dirtree.hpp:681
@ DIRTREE_LTYPES_BOOKMARKS
Definition dirtree.hpp:686
@ DIRTREE_IDAPLACE_BOOKMARKS
Definition dirtree.hpp:684
@ DIRTREE_SNIPPETS
IDB-backed script snippets.
Definition dirtree.hpp:687
@ DIRTREE_IMPORTS
Definition dirtree.hpp:683
@ DIRTREE_LOCAL_TYPES
Definition dirtree.hpp:680
@ DIRTREE_NAMES
Definition dirtree.hpp:682
@ DIRTREE_BPTS
Definition dirtree.hpp:685
@ DIRTREE_END
Definition dirtree.hpp:688
idaman dirtree_t *ida_export get_std_dirtree(dirtree_id_t id)
dterr_t
Directory tree: error codes.
Definition dirtree.hpp:213
@ DTE_NOT_DIRECTORY
item is not a directory
Definition dirtree.hpp:217
@ DTE_NOT_ORDERABLE
directory is not orderable
Definition dirtree.hpp:223
@ DTE_CANT_RENAME
failed to rename an item
Definition dirtree.hpp:220
@ DTE_OK
ok
Definition dirtree.hpp:214
@ DTE_MAX_DIR
maximum directory count achieved
Definition dirtree.hpp:222
@ DTE_NOT_FOUND
item not found
Definition dirtree.hpp:216
@ DTE_OWN_CHILD
moving inside subdirectory of itself
Definition dirtree.hpp:221
@ DTE_LAST
Definition dirtree.hpp:224
@ DTE_NOT_EMPTY
directory is not empty
Definition dirtree.hpp:218
@ DTE_BAD_PATH
invalid path
Definition dirtree.hpp:219
@ DTE_ALREADY_EXISTS
item already exists
Definition dirtree.hpp:215
qvector< inode_t > inodevec_t
Definition dirtree.hpp:30
qvector< direntry_t > direntry_vec_t
Definition dirtree.hpp:76
uval_t diridx_t
Directory indexes are simple numbers like 0,1,2,3... They are independent of inode numbers.
Definition dirtree.hpp:35
qvector< dirtree_bulk_result_t > dirtree_bulk_results_t
Definition dirtree.hpp:236
void dirtree_restore_prefix_sep(qstring *s)
Replace DIRTREE_FOLDED_SEP bytes by '/' in-place, for display only.
Definition dirtree.hpp:100
ea_t blob_idx_t
Blob index, used for storing/restoring dirtree_t information.
Definition dirtree.hpp:39
qvector< dirtree_cursor_t > dirtree_cursor_vec_t
Definition dirtree.hpp:197
qvector< diridx_t > dirvec_t
Definition dirtree.hpp:36
DECLARE_TYPE_AS_MOVABLE(direntry_t)
@ DTN_FULL_NAME
use long form of the entry name.
Definition dirtree.hpp:82
@ DTN_DISPLAY_NAME
use short, displayable form of the entry name.
Definition dirtree.hpp:84
uval_t uval_t
Definition kernwin.hpp:1926
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
uint64 ea_t
Definition pro.h:425
THREAD_SAFE void qswap(T &a, T &b)
Swap 2 objects of the same type using memory copies.
Definition pro.h:1728
uval_t inode_t
The inode_t type is the specialization specific inode number.
Definition pro.h:468
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
unsigned char uint8
unsigned 8 bit value
Definition pro.h:348
_qstring< char > qstring
regular string
Definition pro.h:3771
Directory entry: either a file or directory.
Definition dirtree.hpp:48
bool operator!=(const direntry_t &r) const
Definition dirtree.hpp:62
bool isdir
is 'idx' a diridx_t, or an inode_t
Definition dirtree.hpp:50
bool operator<(const direntry_t &r) const
Definition dirtree.hpp:66
bool operator>=(const direntry_t &r) const
Definition dirtree.hpp:72
bool valid() const
Definition dirtree.hpp:56
static const uval_t ROOTIDX
Definition dirtree.hpp:53
uval_t idx
diridx_t or inode_t
Definition dirtree.hpp:49
static const uval_t BADIDX
Definition dirtree.hpp:52
direntry_t(uval_t i=BADIDX, bool d=false)
Definition dirtree.hpp:55
bool operator==(const direntry_t &r) const
Definition dirtree.hpp:58
Directory tree specialization.
Definition dirtree.hpp:110
@ DSF_ORDERABLE
Definition dirtree.hpp:116
@ DSF_UNQ_NAMES
Definition dirtree.hpp:117
@ DSF_PRIVRANGE
Definition dirtree.hpp:115
@ DSF_INODE_EA
Definition dirtree.hpp:114
dirspec_t(const char *nm=nullptr, uint32 f=0)
Definition dirtree.hpp:124
virtual bool rename_inode(inode_t inode, const char *newname)=0
rename the entry
bool unique_names() const
Definition dirtree.hpp:159
virtual bool get_name(qstring *out, inode_t inode, uint32 name_flags=DTN_FULL_NAME)=0
get the entry name.
virtual qstring get_attrs(inode_t inode) const =0
uint32 dsf_flags
Definition dirtree.hpp:111
virtual ~dirspec_t()
Definition dirtree.hpp:126
bool is_orderable() const
Definition dirtree.hpp:158
virtual inode_t get_inode(const char *dirpath, const char *name)=0
get the entry inode in the specified directory
virtual void unlink_inode(inode_t inode)
event: unlinked an inode
Definition dirtree.hpp:156
bool has_inode_ea() const
Definition dirtree.hpp:160
qstring id
Definition dirtree.hpp:122
Definition dirtree.hpp:228
int idx
Definition dirtree.hpp:232
direntry_t entry
Definition dirtree.hpp:230
dterr_t err
Definition dirtree.hpp:231
diridx_t parent
Definition dirtree.hpp:229
Position in the directory tree.
Definition dirtree.hpp:166
dirtree_cursor_t(diridx_t _parent=direntry_t::BADIDX, size_t _rank=size_t(-1))
Definition dirtree.hpp:169
bool valid() const
Definition dirtree.hpp:171
DECLARE_COMPARISONS(dirtree_cursor_t)
Definition dirtree.hpp:187
size_t rank
the index into the parent directory
Definition dirtree.hpp:168
bool is_root_cursor() const
Definition dirtree.hpp:172
diridx_t parent
the parent directory
Definition dirtree.hpp:167
void set_root_cursor()
Definition dirtree.hpp:173
static dirtree_cursor_t root_cursor()
Definition dirtree.hpp:180
void swap(dirtree_cursor_t &r)
Definition dirtree.hpp:174
Helper class to iterate over files.
Definition dirtree.hpp:205
dirtree_cursor_t cursor
Definition dirtree.hpp:207
qstring pattern
Definition dirtree.hpp:206
Definition dirtree.hpp:200
A visitor, for use with dirtree_t::traverse.
Definition dirtree.hpp:245
virtual ssize_t visit(const dirtree_cursor_t &c, const direntry_t &de)=0
Will be called for each entry in the dirtree_t If something other than 0 is returned,...
virtual ~dirtree_visitor_t()
Definition dirtree.hpp:246
Definition moves.hpp:60