X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Ffilesystem.C;h=1d0aee887127385affb67d6f34dec726389437cd;hb=ccd23c15fae578be22d48b1a1e8b09cb43d593ae;hp=50c38a1c14c1c76dbab0a38c5edf09205c9c5fa3;hpb=43821d27c5b51c4250a251f20c98878f54deb288;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/filesystem.C b/cinelerra-5.1/guicast/filesystem.C index 50c38a1c..1d0aee88 100644 --- a/cinelerra-5.1/guicast/filesystem.C +++ b/cinelerra-5.1/guicast/filesystem.C @@ -44,8 +44,7 @@ FileItem::FileItem() } FileItem::FileItem(char *path, char *name, int is_dir, - int64_t size, int month, int day, int year, - int64_t calendar_time, int item_no) + int64_t size, time_t mtime, int item_no) { this->path = new char[strlen(path)]; this->name = new char[strlen(name)]; @@ -53,10 +52,7 @@ FileItem::FileItem(char *path, char *name, int is_dir, if(this->name) strcpy(this->name, name); this->is_dir = is_dir; this->size = size; - this->month = month; - this->day = day; - this->year = year; - this->calendar_time = calendar_time; + this->mtime = mtime; this->item_no = item_no; } @@ -73,10 +69,7 @@ int FileItem::reset() name = 0; is_dir = 0; size = 0; - month = 0; - day = 0; - year = 0; - calendar_time = 0; + mtime = 0; item_no = -1; return 0; } @@ -97,21 +90,6 @@ int FileItem::set_name(char *name) return 0; } -const char* FileItem::get_path() -{ - return path; -} - -const char* FileItem::get_name() -{ - return name; -} - -int FileItem::get_is_dir() -{ - return is_dir; -} - FileSystem::FileSystem() @@ -221,18 +199,18 @@ int FileSystem::date_ascending(const void *ptr1, const void *ptr2) { FileItem *item1 = *(FileItem**)ptr1; FileItem *item2 = *(FileItem**)ptr2; - return item1->calendar_time == item2->calendar_time ? + return item1->mtime == item2->mtime ? item1->item_no - item2->item_no : - item1->calendar_time > item2->calendar_time; + item1->mtime > item2->mtime; } int FileSystem::date_descending(const void *ptr1, const void *ptr2) { FileItem *item1 = *(FileItem**)ptr1; FileItem *item2 = *(FileItem**)ptr2; - return item2->calendar_time == item1->calendar_time ? + return item2->mtime == item1->mtime ? item2->item_no - item1->item_no : - item2->calendar_time > item1->calendar_time; + item2->mtime > item1->mtime; } int FileSystem::ext_ascending(const void *ptr1, const void *ptr2) @@ -306,17 +284,6 @@ int FileSystem::combine(ArrayList *dir_list, ArrayList *fi return 0; } -void FileSystem::alphabetize() -{ - sort_table(&dir_list); -} - -int FileSystem::is_root_dir(char *path) -{ - if(!strcmp(current_dir, "/")) return 1; - return 0; -} - int FileSystem::test_filter(FileItem *file) { char *filter1 = 0, *filter2 = filter, *subfilter1, *subfilter2; @@ -464,7 +431,7 @@ int FileSystem::scan_directory(const char *new_dir) new_file = new FileItem; char full_path[BCTEXTLEN], name_only[BCTEXTLEN]; sprintf(full_path, "%s", current_dir); - if(!is_root_dir(current_dir)) strcat(full_path, "/"); + add_end_slash(full_path); strcat(full_path, new_filename->d_name); strcpy(name_only, new_filename->d_name); new_file->set_path(full_path); @@ -475,11 +442,7 @@ int FileSystem::scan_directory(const char *new_dir) if(!stat(full_path, &ostat)) { new_file->size = ostat.st_size; - struct tm *mod_time = localtime(&(ostat.st_mtime)); - new_file->month = mod_time->tm_mon + 1; - new_file->day = mod_time->tm_mday; - new_file->year = mod_time->tm_year + 1900; - new_file->calendar_time = ostat.st_mtime; + new_file->mtime = ostat.st_mtime; if(S_ISDIR(ostat.st_mode)) { @@ -507,6 +470,7 @@ int FileSystem::scan_directory(const char *new_dir) delete new_file; } } + closedir(dirstream); return 0; } @@ -632,33 +596,12 @@ int FileSystem::parse_tildas(char *new_dir) int FileSystem::parse_directories(char *new_dir) { //printf("FileSystem::parse_directories 1 %s\n", new_dir); - if(new_dir[0] != '/') - { -// extend path completely + if( *new_dir != '/' && current_dir[0] ) { // expand to abs path char string[BCTEXTLEN]; -//printf("FileSystem::parse_directories 2 %s\n", current_dir); - if(!strlen(current_dir)) - { -// no current directory - strcpy(string, new_dir); - } - else - if(!is_root_dir(current_dir)) - { -// current directory is not root - if(current_dir[strlen(current_dir) - 1] == '/') -// current_dir already has ending / - sprintf(string, "%s%s", current_dir, new_dir); - else -// need ending / - sprintf(string, "%s/%s", current_dir, new_dir); - } - else - sprintf(string, "%s%s", current_dir, new_dir); - -//printf("FileSystem::parse_directories 3 %s %s\n", new_dir, string); + strcpy(string, current_dir); + add_end_slash(string); + strcat(string, new_dir); strcpy(new_dir, string); -//printf("FileSystem::parse_directories 4\n"); } return 0; } @@ -852,22 +795,6 @@ int FileSystem::add_end_slash(char *new_dir) return 0; } -char* FileSystem::get_current_dir() -{ - return current_dir; -} - -int FileSystem::total_files() -{ - return dir_list.total; -} - - -FileItem* FileSystem::get_entry(int entry) -{ - return dir_list.values[entry]; -} - // collapse ".", "..", "//" eg. x/./..//y = y char *FileSystem::basepath(const char *path)