1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* This file is part of the XForms library package.
*
* XForms is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1, or
* (at your option) any later version.
*
* XForms is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with XForms. If not, see <http://www.gnu.org/licenses/>.
*/
/********************** crop here for forms.h **********************/
/**
* \file filesys.h
*
* Convenience functions to read a directory
*/
#ifndef FL_FILESYS_H
#define FL_FILESYS_H
/* File types */
enum {
FT_FILE,
FT_DIR,
FT_LINK,
FT_SOCK,
FT_FIFO,
FT_BLK,
FT_CHR,
FT_OTHER
};
typedef struct {
char * name; /* entry name */
int type; /* FILE_TYPE */
long dl_mtime; /* file modification time */
unsigned long dl_size; /* file size in bytes */
} FL_Dirlist;
enum {
FL_ALPHASORT = 1, /* sort in alphabetic order */
FL_RALPHASORT, /* sort in reverse alphabetic order */
FL_MTIMESORT, /* sort according to modifcation time */
FL_RMTIMESORT, /* sort in reverse modificaiton time */
FL_SIZESORT, /* sort in increasing size order */
FL_RSIZESORT, /* sort in decreasing size order */
FL_CASEALPHASORT, /* sort case insensitive */
FL_RCASEALPHASORT /* sort case insensitive */
};
typedef int ( * FL_DIRLIST_FILTER )( const char *, int );
/* read dir with pattern filtering. All dirs read might be cached.
* must not change dirlist in anyway. */
FL_EXPORT const FL_Dirlist * fl_get_dirlist( const char * dir,
const char * pattern,
int * n,
int rescan );
FL_EXPORT FL_DIRLIST_FILTER fl_set_dirlist_filter( FL_DIRLIST_FILTER filter );
FL_EXPORT int fl_set_dirlist_sort( int method );
FL_EXPORT int fl_set_dirlist_filterdir( int yes );
FL_EXPORT void fl_free_dirlist( FL_Dirlist * dl );
/* Free all directory caches */
FL_EXPORT void fl_free_all_dirlist( void );
FL_EXPORT int fl_is_valid_dir( const char * name );
FL_EXPORT unsigned long fl_fmtime( const char * s );
FL_EXPORT char * fl_fix_dirname( char * dir );
#endif /* ! defined FL_FILESYS_H */
|