Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

filesystem.h

Go to the documentation of this file.
00001 #ifndef FILESYSTEM_H
00002 #define FILESYSTEM_H
00003 
00004 #include "arraylist.h"
00005 #include "bcwindowbase.inc"
00006 #include "sizes.h"
00007 
00008 class FileItem
00009 {
00010 public:
00011         FileItem();
00012         FileItem(char *path, 
00013                 char *name, 
00014                 int is_dir, 
00015                 int64_t size, 
00016                 int month, 
00017                 int day, 
00018                 int year,
00019                 int64_t calendar_time);
00020         ~FileItem();
00021 
00022         int set_path(char *path);
00023         int set_name(char *name);
00024         int reset();
00025         char *path;
00026         char *name;
00027         int is_dir;
00028         int64_t size;
00029         int month;
00030         int day;
00031         int year;
00032         int64_t calendar_time;
00033 };
00034 
00035 class FileSystem
00036 {
00037 public:
00038 // sets the working directory to the user
00039         FileSystem();
00040         virtual ~FileSystem();
00041 
00042 // Load the new directory and change current_dir to it.
00043 // This does not complete the dir path.
00044 // If any of the files failed to stat, it returns nonzero.
00045         int update(char *new_dir = 0);
00046 
00047 // Complete the path in the string and change to the directory in the string.
00048 // Does not change new_dir
00049         int change_dir(char *new_dir);
00050 // Set the current_dir to something without completing the path.
00051         int set_current_dir(char *new_dir);
00052 
00053         int move_up();
00054         char *get_current_dir();
00055 // Syntax of filter is
00056 // single filter without [].
00057 // multiple filters enclosed in [].
00058         int set_filter(char *new_filter);
00059         int set_show_all();     // show hidden files
00060         int set_want_directory();
00061         int set_sort_order(int value);
00062         int set_sort_field(int field);
00063         int create_dir(char *new_dir_);    // create a new directory
00064         int complete_path(char *filename);   // use the filename and the current_dir to create a complete filename
00065         int is_dir(const char *new_dir_);         // return 0 if the text is a directory
00066         int extract_dir(char *out, const char *in);    // extract the directory from the path
00067         int extract_name(char *out, const char *in, int test_dir = 1);  // extract the name from the path
00068         int join_names(char *out, char *dir_in, char *name_in);    // combine a directory and filename
00069         long get_date(char *filename);        // get the date of the filename modification
00070         static int64_t get_size(char *filename);        // Get the number of bytes in the file.
00071         int add_end_slash(char *new_dir);
00072         int total_files();
00073         FileItem* get_entry(int entry);
00074 
00075         int parse_tildas(char *new_dir);     // expand tildas
00076         int parse_directories(char *new_dir);  // add directories
00077         int parse_dots(char *new_dir);         // move up directory tree after expanding tildas
00078 
00079 // Alphabetize all the directories and files.  By default
00080 // directories come first.
00081         void alphabetize();
00082 
00083 // Array of files and directories in the directory pointed to by current_dir.
00084 // Directories are first.
00085         ArrayList<FileItem*> dir_list;
00086 
00087 // Sorting order and sorting field.  These are identical in BC_ListBox.
00088         enum
00089         {
00090                 SORT_ASCENDING,
00091                 SORT_DESCENDING
00092         };
00093 
00094 // Match column definitions in BC_FileBox.
00095         enum
00096         {
00097                 SORT_PATH,
00098                 SORT_SIZE,
00099                 SORT_DATE,
00100                 SORT_EXTENSION
00101         };
00102 
00103 private:
00104         int dot_reverse_filename(char *out, const char *in);
00105         int compare_items(ArrayList<FileItem*> *dir_list, int item1, int item2);
00106         int sort_table(ArrayList<FileItem*> *dir_list);
00107 
00108 
00109 // Combine the directories and files into the master list, directories first.
00110         int combine(ArrayList<FileItem*> *dir_list, ArrayList<FileItem*> *file_list);
00111 // Return whether or not the string is the root directory.
00112         int is_root_dir(char *path);
00113 // Whether or not the file passes the current filter.
00114         int test_filter(FileItem *file);
00115         int reset_parameters();
00116         int delete_directory();
00117         char filter[BCTEXTLEN];     // what filenames have to end in to get displayed
00118         int want_directory;
00119         int show_all_files;       // shows . files
00120         char current_dir[BCTEXTLEN];
00121         char string[BCTEXTLEN], string2[BCTEXTLEN];
00122         int sort_order;
00123         int sort_field;
00124 };
00125 
00126 #endif

Generated on Sun Jan 8 13:26:34 2006 for Guicast-svn by  doxygen 1.4.4