4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2007 Blender Foundation.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
47 #include "MEM_guardedalloc.h"
49 #include "BLI_blenlib.h"
50 #include "BLI_linklist.h"
51 #include "BLI_storage_types.h"
52 #include "BLI_threads.h"
55 #include "BLI_winstuff.h"
58 #include "BKE_utildefines.h"
59 #include "BKE_global.h"
60 #include "BKE_library.h"
61 #include "BKE_global.h"
63 #include "BLO_readfile.h"
65 #include "DNA_space_types.h"
66 #include "DNA_ipo_types.h"
68 #include "DNA_object_types.h"
69 #include "DNA_listBase.h"
70 #include "DNA_lamp_types.h"
71 #include "DNA_material_types.h"
72 #include "DNA_texture_types.h"
73 #include "DNA_world_types.h"
74 #include "DNA_scene_types.h"
75 #include "DNA_userdef_types.h"
77 #include "ED_datafiles.h"
79 #include "IMB_imbuf.h"
80 #include "IMB_imbuf_types.h"
81 #include "IMB_thumbs.h"
89 /* Elubie: VERY, really very ugly and evil! Remove asap!!! */
90 /* for state of file */
93 /* max length of library group name within filesel */
96 static void *exec_loadimages(void *list_v);
100 typedef struct FileImage {
101 struct FileImage *next, *prev;
105 struct FileList* filelist;
108 typedef struct FileList
110 struct direntry *filelist;
128 #define SPECIAL_IMG_SIZE 48
129 #define SPECIAL_IMG_ROWS 4
130 #define SPECIAL_IMG_COLS 4
132 #define SPECIAL_IMG_FOLDER 0
133 #define SPECIAL_IMG_PARENT 1
134 #define SPECIAL_IMG_REFRESH 2
135 #define SPECIAL_IMG_BLENDFILE 3
136 #define SPECIAL_IMG_SOUNDFILE 4
137 #define SPECIAL_IMG_MOVIEFILE 5
138 #define SPECIAL_IMG_PYTHONFILE 6
139 #define SPECIAL_IMG_TEXTFILE 7
140 #define SPECIAL_IMG_FONTFILE 8
141 #define SPECIAL_IMG_UNKNOWNFILE 9
142 #define SPECIAL_IMG_LOADING 10
143 #define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1
145 static ImBuf* gSpecialFileImages[SPECIAL_IMG_MAX];
148 /* ******************* SORT ******************* */
150 static int compare_name(const void *a1, const void *a2)
152 const struct direntry *entry1=a1, *entry2=a2;
154 /* type is is equal to stat.st_mode */
156 if (S_ISDIR(entry1->type)){
157 if (S_ISDIR(entry2->type)==0) return (-1);
159 if (S_ISDIR(entry2->type)) return (1);
161 if (S_ISREG(entry1->type)){
162 if (S_ISREG(entry2->type)==0) return (-1);
164 if (S_ISREG(entry2->type)) return (1);
166 if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
167 if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
169 /* make sure "." and ".." are always first */
170 if( strcmp(entry1->relname, ".")==0 ) return (-1);
171 if( strcmp(entry2->relname, ".")==0 ) return (1);
172 if( strcmp(entry1->relname, "..")==0 ) return (-1);
173 if( strcmp(entry2->relname, "..")==0 ) return (1);
175 return (BLI_strcasecmp(entry1->relname,entry2->relname));
178 static int compare_date(const void *a1, const void *a2)
180 const struct direntry *entry1=a1, *entry2=a2;
182 /* type is equal to stat.st_mode */
184 if (S_ISDIR(entry1->type)){
185 if (S_ISDIR(entry2->type)==0) return (-1);
187 if (S_ISDIR(entry2->type)) return (1);
189 if (S_ISREG(entry1->type)){
190 if (S_ISREG(entry2->type)==0) return (-1);
192 if (S_ISREG(entry2->type)) return (1);
194 if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
195 if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
197 /* make sure "." and ".." are always first */
198 if( strcmp(entry1->relname, ".")==0 ) return (-1);
199 if( strcmp(entry2->relname, ".")==0 ) return (1);
200 if( strcmp(entry1->relname, "..")==0 ) return (-1);
201 if( strcmp(entry2->relname, "..")==0 ) return (1);
203 if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1;
204 if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1;
206 else return BLI_strcasecmp(entry1->relname,entry2->relname);
209 static int compare_size(const void *a1, const void *a2)
211 const struct direntry *entry1=a1, *entry2=a2;
213 /* type is equal to stat.st_mode */
215 if (S_ISDIR(entry1->type)){
216 if (S_ISDIR(entry2->type)==0) return (-1);
218 if (S_ISDIR(entry2->type)) return (1);
220 if (S_ISREG(entry1->type)){
221 if (S_ISREG(entry2->type)==0) return (-1);
223 if (S_ISREG(entry2->type)) return (1);
225 if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
226 if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
228 /* make sure "." and ".." are always first */
229 if( strcmp(entry1->relname, ".")==0 ) return (-1);
230 if( strcmp(entry2->relname, ".")==0 ) return (1);
231 if( strcmp(entry1->relname, "..")==0 ) return (-1);
232 if( strcmp(entry2->relname, "..")==0 ) return (1);
234 if ( entry1->s.st_size < entry2->s.st_size) return 1;
235 if ( entry1->s.st_size > entry2->s.st_size) return -1;
236 else return BLI_strcasecmp(entry1->relname,entry2->relname);
239 static int compare_extension(const void *a1, const void *a2) {
240 const struct direntry *entry1=a1, *entry2=a2;
241 char *sufix1, *sufix2;
244 if (!(sufix1= strstr (entry1->relname, ".blend.gz")))
245 sufix1= strrchr (entry1->relname, '.');
246 if (!(sufix2= strstr (entry2->relname, ".blend.gz")))
247 sufix2= strrchr (entry2->relname, '.');
248 if (!sufix1) sufix1= nil;
249 if (!sufix2) sufix2= nil;
251 /* type is is equal to stat.st_mode */
253 if (S_ISDIR(entry1->type)){
254 if (S_ISDIR(entry2->type)==0) return (-1);
256 if (S_ISDIR(entry2->type)) return (1);
258 if (S_ISREG(entry1->type)){
259 if (S_ISREG(entry2->type)==0) return (-1);
261 if (S_ISREG(entry2->type)) return (1);
263 if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
264 if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
266 /* make sure "." and ".." are always first */
267 if( strcmp(entry1->relname, ".")==0 ) return (-1);
268 if( strcmp(entry2->relname, ".")==0 ) return (1);
269 if( strcmp(entry1->relname, "..")==0 ) return (-1);
270 if( strcmp(entry2->relname, "..")==0 ) return (1);
272 return (BLI_strcasecmp(sufix1, sufix2));
275 void filelist_filter(FileList* filelist)
277 char dir[FILE_MAX], group[GROUP_MAX];
278 int num_filtered = 0;
281 if (!filelist->filelist)
284 if (!filelist->filter) {
285 if (filelist->fidx) {
286 MEM_freeN(filelist->fidx);
287 filelist->fidx = NULL;
289 filelist->fidx = (int *)MEM_callocN(filelist->numfiles*sizeof(int), "filteridx");
290 for (i = 0; i < filelist->numfiles; ++i) {
291 filelist->fidx[i] = i;
293 filelist->numfiltered = filelist->numfiles;
297 // How many files are left after filter ?
298 for (i = 0; i < filelist->numfiles; ++i) {
299 if (filelist->filelist[i].flags & filelist->filter) {
302 else if (filelist->filelist[i].type & S_IFDIR) {
303 if (filelist->filter & FOLDERFILE) {
309 if (filelist->fidx) {
310 MEM_freeN(filelist->fidx);
311 filelist->fidx = NULL;
313 filelist->fidx = (int *)MEM_callocN(num_filtered*sizeof(int), "filteridx");
314 filelist->numfiltered = num_filtered;
316 for (i = 0, j=0; i < filelist->numfiles; ++i) {
317 if (filelist->filelist[i].flags & filelist->filter) {
318 filelist->fidx[j++] = i;
320 else if (filelist->filelist[i].type & S_IFDIR) {
321 if (filelist->filter & FOLDERFILE) {
322 filelist->fidx[j++] = i;
328 void filelist_init_icons()
333 bbuf = IMB_ibImageFromMemory((int *)datatoc_prvicons, datatoc_prvicons_size, IB_rect);
335 for (y=0; y<SPECIAL_IMG_ROWS; y++) {
336 for (x=0; x<SPECIAL_IMG_COLS; x++) {
337 int tile = SPECIAL_IMG_COLS*y + x;
338 if (tile < SPECIAL_IMG_MAX) {
339 ibuf = IMB_allocImBuf(SPECIAL_IMG_SIZE, SPECIAL_IMG_SIZE, 32, IB_rect, 0);
340 for (k=0; k<SPECIAL_IMG_SIZE; k++) {
341 memcpy(&ibuf->rect[k*SPECIAL_IMG_SIZE], &bbuf->rect[(k+y*SPECIAL_IMG_SIZE)*SPECIAL_IMG_SIZE*SPECIAL_IMG_COLS+x*SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE*sizeof(int));
343 gSpecialFileImages[tile] = ibuf;
351 void filelist_free_icons()
354 for (i=0; i < SPECIAL_IMG_MAX; ++i) {
355 IMB_freeImBuf(gSpecialFileImages[i]);
356 gSpecialFileImages[i] = NULL;
360 struct FileList* filelist_new()
362 FileList* p = MEM_callocN( sizeof(FileList), "filelist" );
372 struct FileList* filelist_copy(struct FileList* filelist)
374 FileList* p = filelist_new();
375 BLI_strncpy(p->dir, filelist->dir, FILE_MAX);
378 p->type = filelist->type;
383 void filelist_free(struct FileList* filelist)
388 printf("Attemtping to delete empty filelist.\n");
392 BLI_end_threads(&filelist->threads);
393 BLI_freelistN(&filelist->loadimages);
395 if (filelist->fidx) {
396 MEM_freeN(filelist->fidx);
397 filelist->fidx = NULL;
400 for (i = 0; i < filelist->numfiles; ++i) {
401 if (filelist->filelist[i].image) {
402 IMB_freeImBuf(filelist->filelist[i].image);
404 filelist->filelist[i].image = 0;
405 if (filelist->filelist[i].relname)
406 MEM_freeN(filelist->filelist[i].relname);
407 filelist->filelist[i].relname = 0;
408 if (filelist->filelist[i].string)
409 MEM_freeN(filelist->filelist[i].string);
410 filelist->filelist[i].string = 0;
413 filelist->numfiles = 0;
414 free(filelist->filelist);
415 filelist->filelist = 0;
416 filelist->filter = 0;
417 filelist->numfiltered =0;
420 int filelist_numfiles(struct FileList* filelist)
422 return filelist->numfiltered;
425 const char * filelist_dir(struct FileList* filelist)
427 return filelist->dir;
430 void filelist_setdir(struct FileList* filelist, const char *dir)
432 BLI_strncpy(filelist->dir, dir, FILE_MAX);
435 void filelist_imgsize(struct FileList* filelist, short w, short h)
442 static void *exec_loadimages(void *list_v)
444 FileImage* img = (FileImage*)list_v;
445 struct FileList *filelist = img->filelist;
448 int fidx = img->index;
450 if ( filelist->filelist[fidx].flags & IMAGEFILE ) {
451 imb = IMB_thumb_manage(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL, THB_SOURCE_IMAGE);
452 } else if ( filelist->filelist[fidx].flags & MOVIEFILE ) {
453 imb = IMB_thumb_manage(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL, THB_SOURCE_MOVIE);
455 /* remember that file can't be loaded via IMB_open_anim */
456 filelist->filelist[fidx].flags &= ~MOVIEFILE;
457 filelist->filelist[fidx].flags |= MOVIEFILE_ICON;
467 short filelist_changed(struct FileList* filelist)
469 return filelist->changed;
472 void filelist_loadimage_timer(struct FileList* filelist)
474 FileImage *limg = filelist->loadimages.first;
477 // as long as threads are available and there is work to do
479 if (BLI_available_threads(&filelist->threads)>0) {
482 BLI_insert_thread(&filelist->threads, limg);
486 FileImage *oimg = limg;
487 BLI_remlink(&filelist->loadimages, oimg);
488 BLI_remove_thread(&filelist->threads, oimg);
496 filelist->changed=refresh;
499 void filelist_loadimage(struct FileList* filelist, int index)
502 int imgwidth = filelist->prv_w;
503 int imgheight = filelist->prv_h;
504 short ex, ey, dx, dy;
505 float scaledx, scaledy;
508 if ( (index < 0) || (index >= filelist->numfiltered) ) {
511 fidx = filelist->fidx[index];
513 if (!filelist->filelist[fidx].image)
515 if (filelist->type != FILE_MAIN)
517 if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) {
518 imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL);
521 if (imb->x > imb->y) {
522 scaledx = (float)imgwidth;
523 scaledy = ( (float)imb->y/(float)imb->x )*imgwidth;
526 scaledy = (float)imgheight;
527 scaledx = ( (float)imb->x/(float)imb->y )*imgheight;
535 IMB_scaleImBuf(imb, ex, ey);
536 filelist->filelist[fidx].image = imb;
538 /* prevent loading image twice */
539 FileImage* limg = filelist->loadimages.first;
542 if (limg->index == fidx) {
549 FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage");
552 limg->filelist= filelist;
553 BLI_addtail(&filelist->loadimages, limg);
560 struct ImBuf * filelist_getimage(struct FileList* filelist, int index)
564 if ( (index < 0) || (index >= filelist->numfiltered) ) {
567 fidx = filelist->fidx[index];
568 ibuf = filelist->filelist[fidx].image;
573 struct ImBuf * filelist_geticon(struct FileList* filelist, int index)
576 struct direntry *file= NULL;
578 if ( (index < 0) || (index >= filelist->numfiltered) ) {
581 fidx = filelist->fidx[index];
582 file = &filelist->filelist[fidx];
583 if (file->type & S_IFDIR) {
584 if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) {
585 ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT];
586 } else if ( strcmp(filelist->filelist[fidx].relname, ".") == 0) {
587 ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH];
589 ibuf = gSpecialFileImages[SPECIAL_IMG_FOLDER];
592 ibuf = gSpecialFileImages[SPECIAL_IMG_UNKNOWNFILE];
595 if (file->flags & BLENDERFILE) {
596 ibuf = gSpecialFileImages[SPECIAL_IMG_BLENDFILE];
597 } else if ( (file->flags & MOVIEFILE) || (file->flags & MOVIEFILE_ICON) ) {
598 ibuf = gSpecialFileImages[SPECIAL_IMG_MOVIEFILE];
599 } else if (file->flags & SOUNDFILE) {
600 ibuf = gSpecialFileImages[SPECIAL_IMG_SOUNDFILE];
601 } else if (file->flags & PYSCRIPTFILE) {
602 ibuf = gSpecialFileImages[SPECIAL_IMG_PYTHONFILE];
603 } else if (file->flags & FTFONTFILE) {
604 ibuf = gSpecialFileImages[SPECIAL_IMG_FONTFILE];
605 } else if (file->flags & TEXTFILE) {
606 ibuf = gSpecialFileImages[SPECIAL_IMG_TEXTFILE];
607 } else if (file->flags & IMAGEFILE) {
608 ibuf = gSpecialFileImages[SPECIAL_IMG_LOADING];
614 struct direntry * filelist_file(struct FileList* filelist, int index)
618 if ( (index < 0) || (index >= filelist->numfiltered) ) {
621 fidx = filelist->fidx[index];
623 return &filelist->filelist[fidx];
626 int filelist_find(struct FileList* filelist, char *file)
636 for (i = 0; i < filelist->numfiles; ++i) {
637 if ( strcmp(filelist->filelist[i].relname, file) == 0) {
643 for (i = 0; i < filelist->numfiltered; ++i) {
644 if (filelist->fidx[i] == index) {
652 void filelist_hidedot(struct FileList* filelist, short hide)
654 filelist->hide_dot = hide;
657 void filelist_setfilter(struct FileList* filelist, unsigned int filter)
659 filelist->filter = filter;
662 int filelist_maxnamelen(struct FileList* filelist)
664 return filelist->maxnamelen;
667 void filelist_readdir(struct FileList* filelist)
673 if (!filelist) return;
675 filelist->filelist = 0;
679 BLI_cleanup_dir(G.sce, filelist->dir);
680 BLI_hide_dot_files(filelist->hide_dot);
681 filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
684 filelist_setfiletypes(filelist, G.have_quicktime);
685 filelist_filter(filelist);
687 if (!filelist->threads.first) {
688 BLI_init_threads(&filelist->threads, exec_loadimages, 2);
691 filelist->maxnamelen = 0;
692 for (i=0; (i < filelist->numfiles); ++i)
694 struct direntry* file = filelist_file(filelist, i);
696 int len = UI_GetStringWidth(G.font, file->relname,0)+UI_GetStringWidth(G.font, file->size,0);
697 if (len > filelist->maxnamelen) filelist->maxnamelen = len;
702 int filelist_empty(struct FileList* filelist)
704 return filelist->filelist == 0;
707 void filelist_parent(struct FileList* filelist)
709 BLI_parent_dir(filelist->dir);
710 BLI_make_exist(filelist->dir);
711 filelist_readdir(filelist);
714 void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
716 struct direntry *file;
719 file= filelist->filelist;
721 for(num=0; num<filelist->numfiles; num++, file++) {
723 file->type= file->s.st_mode; /* restore the mess below */
725 /* Don't check extensions for directories */
726 if (file->type & S_IFDIR)
731 if(BLO_has_bfile_extension(file->relname)) {
732 file->flags |= BLENDERFILE;
733 if(filelist->type==FILE_LOADLIB) {
734 char name[FILE_MAXDIR+FILE_MAXFILE];
735 BLI_strncpy(name, filelist->dir, sizeof(name));
736 strcat(name, file->relname);
738 /* prevent current file being used as acceptable dir */
739 if (BLI_streq(G.main->name, name)==0) {
740 file->type &= ~S_IFMT;
741 file->type |= S_IFDIR;
744 } else if(BLI_testextensie(file->relname, ".py")) {
745 file->flags |= PYSCRIPTFILE;
746 } else if(BLI_testextensie(file->relname, ".txt")) {
747 file->flags |= TEXTFILE;
748 } else if( BLI_testextensie(file->relname, ".ttf")
749 || BLI_testextensie(file->relname, ".ttc")
750 || BLI_testextensie(file->relname, ".pfb")
751 || BLI_testextensie(file->relname, ".otf")
752 || BLI_testextensie(file->relname, ".otc")) {
753 file->flags |= FTFONTFILE;
754 } else if (has_quicktime){
755 if( BLI_testextensie(file->relname, ".int")
756 || BLI_testextensie(file->relname, ".inta")
757 || BLI_testextensie(file->relname, ".jpg")
759 || BLI_testextensie(file->relname, ".jp2")
761 || BLI_testextensie(file->relname, ".jpeg")
762 || BLI_testextensie(file->relname, ".tga")
763 || BLI_testextensie(file->relname, ".rgb")
764 || BLI_testextensie(file->relname, ".rgba")
765 || BLI_testextensie(file->relname, ".bmp")
766 || BLI_testextensie(file->relname, ".png")
767 || BLI_testextensie(file->relname, ".iff")
768 || BLI_testextensie(file->relname, ".lbm")
769 || BLI_testextensie(file->relname, ".gif")
770 || BLI_testextensie(file->relname, ".psd")
771 || BLI_testextensie(file->relname, ".tif")
772 || BLI_testextensie(file->relname, ".tiff")
773 || BLI_testextensie(file->relname, ".pct")
774 || BLI_testextensie(file->relname, ".pict")
775 || BLI_testextensie(file->relname, ".pntg") //macpaint
776 || BLI_testextensie(file->relname, ".qtif")
777 || BLI_testextensie(file->relname, ".sgi")
778 || BLI_testextensie(file->relname, ".hdr")
780 || BLI_testextensie(file->relname, ".dds")
783 || BLI_testextensie(file->relname, ".exr")
786 file->flags |= IMAGEFILE;
788 else if(BLI_testextensie(file->relname, ".avi")
789 || BLI_testextensie(file->relname, ".flc")
790 || BLI_testextensie(file->relname, ".mov")
791 || BLI_testextensie(file->relname, ".movie")
792 || BLI_testextensie(file->relname, ".mp4")
793 || BLI_testextensie(file->relname, ".m4v")
794 || BLI_testextensie(file->relname, ".mv")) {
795 file->flags |= MOVIEFILE;
797 else if(BLI_testextensie(file->relname, ".wav")) {
798 file->flags |= SOUNDFILE;
800 } else { // no quicktime
801 if(BLI_testextensie(file->relname, ".int")
802 || BLI_testextensie(file->relname, ".inta")
803 || BLI_testextensie(file->relname, ".jpg")
804 || BLI_testextensie(file->relname, ".jpeg")
806 || BLI_testextensie(file->relname, ".jp2")
808 || BLI_testextensie(file->relname, ".tga")
809 || BLI_testextensie(file->relname, ".rgb")
810 || BLI_testextensie(file->relname, ".rgba")
811 || BLI_testextensie(file->relname, ".bmp")
812 || BLI_testextensie(file->relname, ".png")
813 || BLI_testextensie(file->relname, ".iff")
814 || BLI_testextensie(file->relname, ".tif")
815 || BLI_testextensie(file->relname, ".tiff")
816 || BLI_testextensie(file->relname, ".hdr")
818 || BLI_testextensie(file->relname, ".dds")
821 || BLI_testextensie(file->relname, ".exr")
823 || BLI_testextensie(file->relname, ".lbm")
824 || BLI_testextensie(file->relname, ".sgi")) {
825 file->flags |= IMAGEFILE;
827 else if(BLI_testextensie(file->relname, ".avi")
828 || BLI_testextensie(file->relname, ".mp4")
829 || BLI_testextensie(file->relname, ".mv")) {
830 file->flags |= MOVIEFILE;
832 else if(BLI_testextensie(file->relname, ".wav")) {
833 file->flags |= SOUNDFILE;
839 void filelist_swapselect(struct FileList* filelist)
841 struct direntry *file;
844 file= filelist->filelist;
845 for(num=0; num<filelist->numfiles; num++, file++) {
846 if(file->flags & ACTIVE) {
851 file= filelist->filelist+2;
852 for(num=2; num<filelist->numfiles; num++, file++) {
853 if(act) file->flags &= ~ACTIVE;
854 else file->flags |= ACTIVE;
858 void filelist_settype(struct FileList* filelist, int type)
860 filelist->type = type;
863 short filelist_gettype(struct FileList* filelist)
865 return filelist->type;
868 void filelist_sort(struct FileList* filelist, short sort)
870 struct direntry *file;
871 int num;/* , act= 0; */
875 qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name);
878 qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date);
881 qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size);
883 case FILE_SORTEXTENS:
884 qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension);
887 file= filelist->filelist;
888 for(num=0; num<filelist->numfiles; num++, file++) {
889 file->flags &= ~HILITE;
891 filelist_filter(filelist);