1
1

* treestore.c (tree_store_start_check_cwd): Eliminate.

(tree_store_start_check): Make globally visible.
* dir.c (do_load_dir): Use path supplied as argument.  Call
tree_store_start_check() after the directory is opened.
(do_reload_dir): Likewise.
Этот коммит содержится в:
Pavel Roskin 2003-10-23 23:37:52 +00:00
родитель ad84a71c64
Коммит f6214df52b
4 изменённых файлов: 46 добавлений и 50 удалений

Просмотреть файл

@ -1,3 +1,11 @@
2003-10-23 Pavel Roskin <proski@gnu.org>
* treestore.c (tree_store_start_check_cwd): Eliminate.
(tree_store_start_check): Make globally visible.
* dir.c (do_load_dir): Use path supplied as argument. Call
tree_store_start_check() after the directory is opened.
(do_reload_dir): Likewise.
2003-10-23 Andrew V. Samoilov <sav@bcs.zp.ua> 2003-10-23 Andrew V. Samoilov <sav@bcs.zp.ua>
* dir.c (do_reload_dir): Fix memory leaks. * dir.c (do_reload_dir): Fix memory leaks.

Просмотреть файл

@ -471,14 +471,12 @@ do_load_dir (char *path, dir_list *list, sortfn *sort, int reverse,
int next_free = 0; int next_free = 0;
struct stat st; struct stat st;
tree_store_start_check_cwd (); dirp = mc_opendir (path);
dirp = mc_opendir (".");
if (!dirp) { if (!dirp) {
message (1, MSG_ERROR, _("Cannot read directory contents")); message (1, MSG_ERROR, _("Cannot read directory contents"));
tree_store_end_check ();
return set_zero_dir (list); return set_zero_dir (list);
} }
tree_store_start_check (path);
for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp)) { for (dp = mc_readdir (dirp); dp; dp = mc_readdir (dirp)) {
status = status =
handle_dirent (list, filter, dp, &st, next_free, &link_to_dir, handle_dirent (list, filter, dp, &st, next_free, &link_to_dir,
@ -578,15 +576,14 @@ do_reload_dir (char *path, dir_list *list, sortfn *sort, int count,
int marked_cnt; int marked_cnt;
GHashTable *marked_files; GHashTable *marked_files;
tree_store_start_check_cwd (); dirp = mc_opendir (path);
dirp = mc_opendir (".");
if (!dirp) { if (!dirp) {
message (1, MSG_ERROR, _("Cannot read directory contents")); message (1, MSG_ERROR, _("Cannot read directory contents"));
clean_dir (list, count); clean_dir (list, count);
tree_store_end_check ();
return set_zero_dir (list); return set_zero_dir (list);
} }
tree_store_start_check (path);
marked_files = g_hash_table_new (g_str_hash, g_str_equal); marked_files = g_hash_table_new (g_str_hash, g_str_equal);
alloc_dir_copy (list->size); alloc_dir_copy (list->size);
for (marked_cnt = i = 0; i < count; i++) { for (marked_cnt = i = 0; i < count; i++) {

Просмотреть файл

@ -633,7 +633,7 @@ tree_store_mark_checked(const char *subname)
} }
/* Mark the subdirectories of the current directory for delete */ /* Mark the subdirectories of the current directory for delete */
static tree_entry * tree_entry *
tree_store_start_check(char *path) tree_store_start_check(char *path)
{ {
tree_entry *current, *retval; tree_entry *current, *retval;
@ -682,15 +682,6 @@ tree_store_start_check(char *path)
return retval; return retval;
} }
tree_entry *
tree_store_start_check_cwd(void)
{
char buffer[MC_MAXPATHLEN];
mc_get_current_wd(buffer, MC_MAXPATHLEN);
return tree_store_start_check(buffer);
}
/* Delete subdirectories which still have the deletion mark */ /* Delete subdirectories which still have the deletion mark */
void void
tree_store_end_check(void) tree_store_end_check(void)

Просмотреть файл

@ -7,49 +7,49 @@
#define MC_TREE_TMP ".mc/Tree.tmp" #define MC_TREE_TMP ".mc/Tree.tmp"
typedef struct tree_entry { typedef struct tree_entry {
char *name; /* The full path of directory */ char *name; /* The full path of directory */
int sublevel; /* Number of parent directories (slashes) */ int sublevel; /* Number of parent directories (slashes) */
long submask; /* Bitmask of existing sublevels after this entry */ long submask; /* Bitmask of existing sublevels after this entry */
char *subname; /* The last part of name (the actual name) */ char *subname; /* The last part of name (the actual name) */
unsigned int mark:1; /* Flag: Is this entry marked (e. g. for delete)? */ unsigned int mark:1; /* Flag: Is this entry marked (e. g. for delete)? */
unsigned int scanned:1; /* Flag: childs scanned or not */ unsigned int scanned:1; /* Flag: childs scanned or not */
struct tree_entry *next; /* Next item in the list */ struct tree_entry *next; /* Next item in the list */
struct tree_entry *prev; /* Previous item in the list */ struct tree_entry *prev; /* Previous item in the list */
} tree_entry; } tree_entry;
typedef struct { typedef struct {
struct tree_entry *base; struct tree_entry *base;
struct tree_entry *current; struct tree_entry *current;
int base_dir_len; int base_dir_len;
int sublevel; int sublevel;
} tree_scan; } tree_scan;
typedef struct { typedef struct {
tree_entry *tree_first; /* First entry in the list */ tree_entry *tree_first; /* First entry in the list */
tree_entry *tree_last; /* Last entry in the list */ tree_entry *tree_last; /* Last entry in the list */
tree_entry *check_start; /* Start of checked subdirectories */ tree_entry *check_start; /* Start of checked subdirectories */
char *check_name; char *check_name;
GList *add_queue; /* List of strings of added directories */ GList *add_queue; /* List of strings of added directories */
unsigned int loaded : 1; unsigned int loaded:1;
unsigned int dirty : 1; unsigned int dirty:1;
} TreeStore; } TreeStore;
TreeStore *tree_store_get (void); TreeStore *tree_store_get (void);
int tree_store_load (void); int tree_store_load (void);
int tree_store_save (void); int tree_store_save (void);
void tree_store_remove_entry (char *name); void tree_store_remove_entry (char *name);
tree_entry *tree_store_start_check_cwd (void); tree_entry *tree_store_start_check (char *path);
void tree_store_mark_checked (const char *subname); void tree_store_mark_checked (const char *subname);
void tree_store_end_check (void); void tree_store_end_check (void);
tree_entry *tree_store_whereis (char *name); tree_entry *tree_store_whereis (char *name);
tree_entry *tree_store_rescan (char *dir); tree_entry *tree_store_rescan (char *dir);
/* /*
* Register/unregister notification functions for "entry_remove" * Register/unregister notification functions for "entry_remove"
*/ */
typedef void (*tree_store_remove_fn)(tree_entry *tree, void *data); typedef void (*tree_store_remove_fn) (tree_entry *tree, void *data);
void tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data); void tree_store_add_entry_remove_hook (tree_store_remove_fn callback,
void tree_store_remove_entry_remove_hook (tree_store_remove_fn callback); void *data);
void tree_store_remove_entry_remove_hook (tree_store_remove_fn callback);
#endif /* !__TREE_STORE_H */
#endif /* !__TREE_STORE_H */