treestore.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /** \file treestore.h
  2. * \brief Header: tree store
  3. *
  4. * Contains a storage of the file system tree representation.
  5. */
  6. #ifndef MC_TREE_STORE_H
  7. #define MC_TREE_STORE_H
  8. typedef struct tree_entry {
  9. char *name; /* The full path of directory */
  10. int sublevel; /* Number of parent directories (slashes) */
  11. long submask; /* Bitmask of existing sublevels after this entry */
  12. const char *subname; /* The last part of name (the actual name) */
  13. unsigned int mark:1; /* Flag: Is this entry marked (e. g. for delete)? */
  14. unsigned int scanned:1; /* Flag: childs scanned or not */
  15. struct tree_entry *next; /* Next item in the list */
  16. struct tree_entry *prev; /* Previous item in the list */
  17. } tree_entry;
  18. struct TreeStore {
  19. tree_entry *tree_first; /* First entry in the list */
  20. tree_entry *tree_last; /* Last entry in the list */
  21. tree_entry *check_start; /* Start of checked subdirectories */
  22. char *check_name;
  23. GList *add_queue; /* List of strings of added directories */
  24. unsigned int loaded:1;
  25. unsigned int dirty:1;
  26. };
  27. struct TreeStore *tree_store_get (void);
  28. int tree_store_load (void);
  29. int tree_store_save (void);
  30. void tree_store_remove_entry (const char *name);
  31. tree_entry *tree_store_start_check (const char *path);
  32. void tree_store_mark_checked (const char *subname);
  33. void tree_store_end_check (void);
  34. tree_entry *tree_store_whereis (const char *name);
  35. tree_entry *tree_store_rescan (const char *dir);
  36. /*
  37. * Register/unregister notification functions for "entry_remove"
  38. */
  39. typedef void (*tree_store_remove_fn) (tree_entry *tree, void *data);
  40. void tree_store_add_entry_remove_hook (tree_store_remove_fn callback,
  41. void *data);
  42. void tree_store_remove_entry_remove_hook (tree_store_remove_fn callback);
  43. #endif