enhanded qse_dir_read()

This commit is contained in:
2011-10-28 01:05:19 +00:00
parent 1b600ee20c
commit e5a9693411
8 changed files with 336 additions and 77 deletions

View File

@ -53,12 +53,16 @@
#define QSE_USECS_PER_MSEC (1000)
#define QSE_NSECS_PER_USEC (1000)
#define QSE_NSECS_PER_MSEC (QSE_NSECS_PER_USEC*QSE_USECS_PER_MSEC)
#define QSE_USECS_PER_SEC (QSE_USECS_PER_MSEC*QSE_MSECS_PER_SEC)
#define QSE_IS_LEAPYEAR(year) ((!((year)%4) && ((year)%100)) || !((year)%400))
#define QSE_DAYS_PER_YEAR(year) \
(QSE_IS_LEAPYEAR(year)? QSE_DAYS_PER_LEAPYEAR: QSE_DAYS_PER_NORMYEAR)
#define QSE_SECNSEC_TO_MSEC(sec,nsec) \
(((qse_ntime_t)(sec) * QSE_MSECS_PER_SEC) + ((qse_ntime_t)(nsec) / QSE_NSECS_PER_MSEC))
/* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970) */
typedef qse_long_t qse_ntime_t;
typedef struct qse_btime_t qse_btime_t;
@ -95,7 +99,6 @@ int qse_gettime (
int qse_settime (
qse_ntime_t nt
);
/******/
/**
@ -137,7 +140,7 @@ int qse_timelocal (
* The qse_strftime() functions formats time.
*/
qse_size_t qse_strftime (
qse_char_t* buf,
qse_char_t* buf,
qse_size_t size,
const qse_char_t* fmt,
qse_btime_t* bt

View File

@ -178,6 +178,15 @@
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#undef HAVE_STRUCT_DIRENT_D_TYPE
/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BIRTHTIME
/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF

View File

@ -23,6 +23,7 @@
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/time.h>
enum qse_dir_errnum_t
{
@ -38,20 +39,46 @@ enum qse_dir_errnum_t
};
typedef enum qse_dir_errnum_t qse_dir_errnum_t;
enum qse_dir_ent_flag_t
{
QSE_DIR_ENT_NAME = (1 << 0),
QSE_DIR_ENT_TYPE = (1 << 1),
QSE_DIR_ENT_SIZE = (1 << 2),
QSE_DIR_ENT_TIME = (1 << 3)
};
enum qse_dir_ent_type_t
{
QSE_DIR_ENT_UNKNOWN,
QSE_DIR_ENT_SUBDIR,
QSE_DIR_ENT_REGULAR,
QSE_DIR_ENT_CHRDEV,
QSE_DIR_ENT_BLKDEV,
QSE_DIR_ENT_SYMLINK,
QSE_DIR_ENT_PIPE
};
typedef enum qse_dir_ent_type_t qse_dir_ent_type_t;
struct qse_dir_ent_t
{
enum
int flags;
struct
{
QSE_DIR_ENT_UNKNOWN,
QSE_DIR_ENT_DIR,
QSE_DIR_ENT_REG,
QSE_DIR_ENT_FIFO,
QSE_DIR_ENT_CHAR,
QSE_DIR_ENT_BLOCK,
QSE_DIR_ENT_LINK
} type;
qse_char_t* name;
qse_foff_t size;
qse_char_t* base;
qse_char_t* path;
} name;
qse_dir_ent_type_t type;
qse_foff_t size;
struct
{
qse_ntime_t create;
qse_ntime_t access;
qse_ntime_t modify;
qse_ntime_t change; /* inode status change */
} time;
};
typedef struct qse_dir_ent_t qse_dir_ent_t;
@ -70,10 +97,10 @@ typedef struct qse_dir_t qse_dir_t;
enum qse_dir_option_t
{
/**< don't follow a symbolic link in qse_dir_change() */
QSE_DIR_NOFOLLOW = (1 << 0),
QSE_DIR_NOFOLLOW = (1 << 1),
/**< check directories against file system in qse_dir_change() */
QSE_DIR_REALPATH = (1 << 1)
QSE_DIR_REALPATH = (1 << 2)
};
#ifdef __cplusplus
@ -109,7 +136,8 @@ const qse_char_t* qse_dir_geterrmsg (
);
qse_dir_ent_t* qse_dir_read (
qse_dir_t* dir
qse_dir_t* dir,
int flags
);
int qse_dir_change (