40#define BAD_BLOB_IDX blob_idx_t(-1)
166 if (
parent < r.parent )
return -1;
167 if (
parent > r.parent )
return 1;
168 if (
rank < r.rank )
return -1;
169 if (
rank > r.rank )
return 1;
229idaman
void ida_export delete_dirtree(dirtree_impl_t *d);
230idaman
bool ida_export load_dirtree(dirtree_impl_t *d);
231idaman
bool ida_export save_dirtree(dirtree_impl_t *d);
232void reset_dirtree(dirtree_impl_t *d);
233idaman
const char *ida_export dirtree_errstr(
dterr_t err);
234idaman
bool ida_export dirtree_is_orderable(
const dirtree_impl_t *d);
235idaman
dterr_t ida_export dirtree_chdir(dirtree_impl_t *d,
const char *path);
236idaman
void ida_export dirtree_getcwd(
qstring *out,
const dirtree_impl_t *d);
237idaman
void ida_export dirtree_resolve_path(
direntry_t *de,
const dirtree_impl_t *d,
const char *path);
239idaman
bool ida_export dirtree_get_entry_name(
qstring *out,
const dirtree_impl_t *d,
const direntry_t &de,
uint32 name_flags);
240idaman
void ida_export dirtree_get_entry_attrs(
qstring *out,
const dirtree_impl_t *d,
const direntry_t &de);
241idaman
bool ida_export dirtree_is_dir_ordered(
const dirtree_impl_t *d,
diridx_t diridx);
242idaman
bool ida_export dirtree_set_natural_order(dirtree_impl_t *d,
diridx_t diridx,
bool enable);
243idaman
ssize_t ida_export dirtree_get_dir_size(dirtree_impl_t *d,
diridx_t diridx);
244idaman
bool ida_export dirtree_findfirst(dirtree_impl_t *d,
dirtree_iterator_t *ff,
const char *pattern);
246idaman
bool ida_export dirtree_get_abspath_by_cursor(
qstring *out,
const dirtree_impl_t *d,
const dirtree_cursor_t &cursor,
uint32 name_flags);
247idaman
bool ida_export dirtree_get_abspath_by_relpath(
qstring *out,
const dirtree_impl_t *d,
const char *relpath);
248idaman
dterr_t ida_export dirtree_mkdir(dirtree_impl_t *d,
const char *path);
249idaman
dterr_t ida_export dirtree_rmdir(dirtree_impl_t *d,
const char *path);
250idaman
dterr_t ida_export dirtree_link(dirtree_impl_t *d,
const char *path,
bool do_link);
251idaman
dterr_t ida_export dirtree_link_inode(dirtree_impl_t *d,
inode_t inode,
bool do_link);
252idaman
dterr_t ida_export dirtree_rename(dirtree_impl_t *d,
const char *from,
const char *to);
254idaman
dterr_t ida_export dirtree_change_rank(dirtree_impl_t *d,
const char *path,
ssize_t rank_delta);
256idaman
void ida_export notify_dirtree(dirtree_impl_t *d,
bool added,
inode_t inode);
257idaman
const char *ida_export dirtree_get_id(
const dirtree_impl_t *d);
258idaman
void ida_export dirtree_set_id(dirtree_impl_t *d,
const char *nm);
259idaman
const char *ida_export dirtree_get_nodename(
const dirtree_impl_t *d);
260idaman
void ida_export dirtree_set_nodename(dirtree_impl_t *d,
const char *nm);
263idaman
dirtree_t *ida_export dirtree_new_shadow_dirtree(dirtree_impl_t *d);
302 dirtree_getcwd(&out, d);
315 dirtree_get_abspath_by_cursor(&out, d, cursor, name_flags);
327 dirtree_get_abspath_by_relpath(&out, d, relpath);
339 dirtree_resolve_cursor(&de, d, cursor);
349 dirtree_resolve_path(&de, d, path);
384 dirtree_get_entry_name(&out, d, de, name_flags);
414 dirtree_get_entry_attrs(&out, d, de);
424 return dirtree_findfirst(d, ff, pattern);
432 return dirtree_findnext(d, ff);
448 dterr_t link(
const char *path) {
return dirtree_link(d, path,
true); }
472 return dirtree_rename(d, from, to);
482 return dirtree_get_rank(d, diridx, de);
494 return dirtree_change_rank(d, path, rank_delta);
503 dirtree_get_parent_cursor(&parent, d, cursor);
515 return load_dirtree(d);
523 return save_dirtree(d);
529 return dirtree_get_id(d);
534 return dirtree_set_id(d, nm);
555 return dirtree_traverse(d, v);
564 dirtree_find_entry(&c,
this, de);
Directory tree.
Definition dirtree.hpp:276
dterr_t link(inode_t inode)
Add an inode into the current directory.
Definition dirtree.hpp:458
bool isdir(const char *path) const
Is a directory?
Definition dirtree.hpp:359
bool isfile(const char *path) const
Is a file?
Definition dirtree.hpp:368
bool is_dir_ordered(diridx_t diridx) const
Is dir ordered?
Definition dirtree.hpp:390
direntry_t resolve_cursor(const dirtree_cursor_t &cursor) const
Resolve cursor.
Definition dirtree.hpp:336
const char * get_id() const
netnode name
Definition dirtree.hpp:527
dterr_t chdir(const char *path)
Change current directory.
Definition dirtree.hpp:295
dterr_t link(const char *path)
Add a file item into a directory.
Definition dirtree.hpp:448
~dirtree_t()
Definition dirtree.hpp:283
static bool isfile(const direntry_t &de)
Definition dirtree.hpp:354
dterr_t rename(const char *from, const char *to)
Rename a directory entry.
Definition dirtree.hpp:470
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:312
void set_id(const char *nm)
Definition dirtree.hpp:532
dirtree_t(dirspec_t *ds)
Definition dirtree.hpp:282
direntry_t resolve_path(const char *path) const
Resolve path.
Definition dirtree.hpp:346
dterr_t change_rank(const char *path, ssize_t rank_delta)
Change ordering rank of an item.
Definition dirtree.hpp:492
bool set_natural_order(diridx_t diridx, bool enable) const
Enable/disable natural inode order in a directory.
Definition dirtree.hpp:400
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:553
dterr_t mkdir(const char *path)
Create a directory.
Definition dirtree.hpp:438
qstring get_entry_attrs(const direntry_t &de) const
Get entry attributes.
Definition dirtree.hpp:411
qstring get_entry_name(const direntry_t &de, uint32 name_flags=DTN_FULL_NAME) const
Get entry name.
Definition dirtree.hpp:379
bool is_orderable() const
Is dirtree orderable?
Definition dirtree.hpp:290
ssize_t get_rank(diridx_t diridx, const direntry_t &de) const
Get ordering rank of an item.
Definition dirtree.hpp:480
bool findfirst(dirtree_iterator_t *ff, const char *pattern) const
Start iterating over files in a directory.
Definition dirtree.hpp:422
dterr_t rmdir(const char *path)
Remove a directory.
Definition dirtree.hpp:443
qstring get_abspath(const char *relpath) const
Construct an absolute path from the specified relative path.
Definition dirtree.hpp:324
bool findnext(dirtree_iterator_t *ff) const
Continue iterating over files in a directory.
Definition dirtree.hpp:430
dirtree_cursor_t find_entry(const direntry_t &de) const
Find the cursor corresponding to an entry of a directory.
Definition dirtree.hpp:561
void notify_dirtree(bool added, inode_t inode)
Notify dirtree about a change of an inode.
Definition dirtree.hpp:540
dterr_t unlink(const char *path)
Remove a file item from a directory.
Definition dirtree.hpp:453
static bool isdir(const direntry_t &de)
Definition dirtree.hpp:353
ssize_t get_dir_size(diridx_t diridx) const
Get dir size.
Definition dirtree.hpp:406
bool load()
Load the tree structure from the netnode.
Definition dirtree.hpp:513
qstring getcwd() const
Get current directory.
Definition dirtree.hpp:299
static const char * errstr(dterr_t err)
Get textual representation of the error code.
Definition dirtree.hpp:286
dterr_t unlink(inode_t inode)
Remove an inode from the current directory.
Definition dirtree.hpp:463
dirtree_cursor_t get_parent_cursor(const dirtree_cursor_t &cursor) const
Get parent cursor.
Definition dirtree.hpp:500
bool save() const
Save the tree structure to the netnode.
Definition dirtree.hpp:521
Reimplementation of vector class from STL.
Definition pro.h:2250
dirtree_id_t
Built-in dirtree specializations:
Definition dirtree.hpp:572
@ DIRTREE_FUNCS
Definition dirtree.hpp:574
@ DIRTREE_LTYPES_BOOKMARKS
Definition dirtree.hpp:579
@ DIRTREE_IDAPLACE_BOOKMARKS
Definition dirtree.hpp:577
@ DIRTREE_IMPORTS
Definition dirtree.hpp:576
@ DIRTREE_LOCAL_TYPES
Definition dirtree.hpp:573
@ DIRTREE_NAMES
Definition dirtree.hpp:575
@ DIRTREE_BPTS
Definition dirtree.hpp:578
@ DIRTREE_END
Definition dirtree.hpp:580
idaman dirtree_t *ida_export get_std_dirtree(dirtree_id_t id)
qvector< inode_t > inodevec_t
Definition dirtree.hpp:30
qvector< direntry_t > direntry_vec_t
Definition dirtree.hpp:75
uval_t diridx_t
Directory indexes are simple numbers like 0,1,2,3... They are independent of inode numbers.
Definition dirtree.hpp:35
dterr_t
Directory tree: error codes.
Definition dirtree.hpp:190
@ DTE_NOT_DIRECTORY
item is not a directory
Definition dirtree.hpp:194
@ DTE_CANT_RENAME
failed to rename an item
Definition dirtree.hpp:197
@ DTE_OK
ok
Definition dirtree.hpp:191
@ DTE_MAX_DIR
maximum directory count achieved
Definition dirtree.hpp:199
@ DTE_NOT_FOUND
item not found
Definition dirtree.hpp:193
@ DTE_OWN_CHILD
moving inside subdirectory of itself
Definition dirtree.hpp:198
@ DTE_LAST
Definition dirtree.hpp:200
@ DTE_NOT_EMPTY
directory is not empty
Definition dirtree.hpp:195
@ DTE_BAD_PATH
invalid path
Definition dirtree.hpp:196
@ DTE_ALREADY_EXISTS
item already exists
Definition dirtree.hpp:192
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:174
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:81
@ DTN_DISPLAY_NAME
use short, displayable form of the entry name.
Definition dirtree.hpp:83
uval_t uval_t
Definition kernwin.hpp:1878
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
uint64 ea_t
Definition pro.h:421
uval_t inode_t
The inode_t type is the specialization specific inode number.
Definition pro.h:464
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
_qstring< char > qstring
regular string
Definition pro.h:3694
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 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:95
uint32 flags
Definition dirtree.hpp:96
@ DSF_ORDERABLE
Definition dirtree.hpp:101
@ DSF_PRIVRANGE
Definition dirtree.hpp:100
@ DSF_INODE_EA
Definition dirtree.hpp:99
dirspec_t(const char *nm=nullptr, uint32 f=0)
Definition dirtree.hpp:108
virtual bool rename_inode(inode_t inode, const char *newname)=0
rename the entry
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
virtual ~dirspec_t()
Definition dirtree.hpp:110
bool is_orderable() const
Definition dirtree.hpp:142
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:140
qstring id
Definition dirtree.hpp:106
Position in the directory tree.
Definition dirtree.hpp:148
dirtree_cursor_t(diridx_t _parent=direntry_t::BADIDX, size_t _rank=size_t(-1))
Definition dirtree.hpp:151
bool valid() const
Definition dirtree.hpp:153
void set_root_cursor(void)
Definition dirtree.hpp:155
DECLARE_COMPARISONS(dirtree_cursor_t)
Definition dirtree.hpp:164
size_t rank
the index into the parent directory
Definition dirtree.hpp:150
bool is_root_cursor() const
Definition dirtree.hpp:154
diridx_t parent
the parent directory
Definition dirtree.hpp:149
static dirtree_cursor_t root_cursor()
Definition dirtree.hpp:157
Helper class to iterate over files.
Definition dirtree.hpp:182
dirtree_cursor_t cursor
Definition dirtree.hpp:184
qstring pattern
Definition dirtree.hpp:183
Definition dirtree.hpp:177
A visitor, for use with dirtree_t::traverse.
Definition dirtree.hpp:210
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:211