r802: Remove renderframfsclient and renderfarmfsserver .h and .C from Makefile.am...
[cinelerra_cv/mob.git] / guicast / filesystem.h
blobd4105504160be27c0d99a06bcdf6ec12d3ade137
1 #ifndef FILESYSTEM_H
2 #define FILESYSTEM_H
4 #include "arraylist.h"
5 #include "bcwindowbase.inc"
6 #include "sizes.h"
8 class FileItem
10 public:
11 FileItem();
12 FileItem(char *path,
13 char *name,
14 int is_dir,
15 int64_t size,
16 int month,
17 int day,
18 int year,
19 int64_t calendar_time);
20 ~FileItem();
22 int set_path(char *path);
23 int set_name(char *name);
24 int reset();
25 char *path;
26 char *name;
27 int is_dir;
28 int64_t size;
29 int month;
30 int day;
31 int year;
32 int64_t calendar_time;
35 class FileSystem
37 public:
38 // sets the working directory to the user
39 FileSystem();
40 virtual ~FileSystem();
42 // Load the new directory and change current_dir to it.
43 // This does not complete the dir path.
44 // If any of the files failed to stat, it returns nonzero.
45 int update(char *new_dir = 0);
47 // Complete the path in the string and change to the directory in the string.
48 // Does not change new_dir
49 int change_dir(char *new_dir);
50 // Set the current_dir to something without completing the path.
51 int set_current_dir(char *new_dir);
53 int move_up();
54 char *get_current_dir();
55 // Syntax of filter is
56 // single filter without [].
57 // multiple filters enclosed in [].
58 int set_filter(char *new_filter);
59 int set_show_all(); // show hidden files
60 int set_want_directory();
61 int set_sort_order(int value);
62 int set_sort_field(int field);
63 int create_dir(char *new_dir_); // create a new directory
64 int complete_path(char *filename); // use the filename and the current_dir to create a complete filename
65 int is_dir(const char *new_dir_); // return 0 if the text is a directory
66 int extract_dir(char *out, const char *in); // extract the directory from the path
67 int extract_name(char *out, const char *in, int test_dir = 1); // extract the name from the path
68 int join_names(char *out, char *dir_in, char *name_in); // combine a directory and filename
69 long get_date(char *filename); // get the date of the filename modification
70 static int64_t get_size(char *filename); // Get the number of bytes in the file.
71 int add_end_slash(char *new_dir);
72 int total_files();
73 FileItem* get_entry(int entry);
75 int parse_tildas(char *new_dir); // expand tildas
76 int parse_directories(char *new_dir); // add directories
77 int parse_dots(char *new_dir); // move up directory tree after expanding tildas
79 // Alphabetize all the directories and files. By default
80 // directories come first.
81 void alphabetize();
83 // Array of files and directories in the directory pointed to by current_dir.
84 // Directories are first.
85 ArrayList<FileItem*> dir_list;
87 // Sorting order and sorting field. These are identical in BC_ListBox.
88 enum
90 SORT_ASCENDING,
91 SORT_DESCENDING
94 // Match column definitions in BC_FileBox.
95 enum
97 SORT_PATH,
98 SORT_SIZE,
99 SORT_DATE,
100 SORT_EXTENSION
103 private:
104 int dot_reverse_filename(char *out, const char *in);
105 int compare_items(ArrayList<FileItem*> *dir_list, int item1, int item2);
106 int sort_table(ArrayList<FileItem*> *dir_list);
109 // Combine the directories and files into the master list, directories first.
110 int combine(ArrayList<FileItem*> *dir_list, ArrayList<FileItem*> *file_list);
111 // Return whether or not the string is the root directory.
112 int is_root_dir(char *path);
113 // Whether or not the file passes the current filter.
114 int test_filter(FileItem *file);
115 int reset_parameters();
116 int delete_directory();
117 char filter[BCTEXTLEN]; // what filenames have to end in to get displayed
118 int want_directory;
119 int show_all_files; // shows . files
120 char current_dir[BCTEXTLEN];
121 char string[BCTEXTLEN], string2[BCTEXTLEN];
122 int sort_order;
123 int sort_field;
126 #endif