sams icons, bsd fixups, lv2 deps
[goodguy/history.git] / cinelerra-5.1 / guicast / filesystem.C
index a3efa4dc7229464eb039e0a820a46fd08adb0ae7..62bf1a5a47573522a7568c8d6aeb91343b393bdc 100644 (file)
@@ -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;
 }
@@ -206,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)
@@ -449,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))
                                {
@@ -481,6 +470,7 @@ int FileSystem::scan_directory(const char *new_dir)
                                delete new_file;
                }
        }
+       closedir(dirstream);
        return 0;
 }
 
@@ -546,9 +536,7 @@ int FileSystem::create_dir(const char *new_dir_)
        char new_dir[BCTEXTLEN];
        strcpy(new_dir, new_dir_);
        complete_path(new_dir);
-
-       mkdir(new_dir, S_IREAD | S_IWRITE | S_IEXEC);
-       return 0;
+       return mkdir(new_dir, S_IRWXU | S_IRWXG | S_IRWXO);
 }
 
 int FileSystem::parse_tildas(char *new_dir)
@@ -606,7 +594,7 @@ 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 != '/' ) {  // expand to abs path
+       if( *new_dir != '/' && current_dir[0] ) {  // expand to abs path
                char string[BCTEXTLEN];
                strcpy(string, current_dir);
                add_end_slash(string);