touched up code a bit

This commit is contained in:
hyung-hwan 2011-10-27 22:29:28 +00:00
parent 4eb8cb62ee
commit 1b600ee20c
4 changed files with 32 additions and 23 deletions

View File

@ -43,8 +43,8 @@ struct qse_dir_ent_t
enum enum
{ {
QSE_DIR_ENT_UNKNOWN, QSE_DIR_ENT_UNKNOWN,
QSE_DIR_ENT_DIRECTORY, QSE_DIR_ENT_DIR,
QSE_DIR_ENT_REGULAR, QSE_DIR_ENT_REG,
QSE_DIR_ENT_FIFO, QSE_DIR_ENT_FIFO,
QSE_DIR_ENT_CHAR, QSE_DIR_ENT_CHAR,
QSE_DIR_ENT_BLOCK, QSE_DIR_ENT_BLOCK,

View File

@ -88,7 +88,7 @@
# define QSE_LLSEEK(handle,hoffset,loffset,out,whence) _llseek(handle,hoffset,loffset,out,whence) # define QSE_LLSEEK(handle,hoffset,loffset,out,whence) _llseek(handle,hoffset,loffset,out,whence)
#endif #endif
#if defined(SYS_lseek65) #if defined(SYS_lseek64)
# define QSE_LSEEK64(handle,offset,whence) syscall(SYS_lseek64,handle,offset,whence) # define QSE_LSEEK64(handle,offset,whence) syscall(SYS_lseek64,handle,offset,whence)
#elif defined(HAVE_lseek64) #elif defined(HAVE_lseek64)
# define QSE_LSEEK64(handle,offset,whence) lseek64(handle,offset,whence) # define QSE_LSEEK64(handle,offset,whence) lseek64(handle,offset,whence)
@ -100,6 +100,18 @@
# define QSE_LSEEK(handle,offset,whence) lseek(handle,offset,whence) # define QSE_LSEEK(handle,offset,whence) lseek(handle,offset,whence)
#endif #endif
#if defined(SYS_lstat64)
# define QSE_LSTAT64(path,stbuf) syscall(SYS_lstat64,path,stbuf)
#elif defined(HAVE_lstat64)
# define QSE_LSTAT64(path,stbuf) lstat64(path,stbuf)
#endif
#if defined(SYS_lstat)
# define QSE_LSTAT(path,stbuf) syscall(SYS_lstat,path,stbuf)
#else
# define QSE_LSTAT(path,stbuf) lstat(path,stbuf)
#endif
#if !defined(_LP64) && defined(SYS_ftruncate64) #if !defined(_LP64) && defined(SYS_ftruncate64)
# define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate64,handle,size) # define QSE_FTRUNCATE(handle,size) syscall(SYS_ftruncate64,handle,size)
#elif defined(SYS_ftruncate) #elif defined(SYS_ftruncate)

View File

@ -30,8 +30,7 @@
#elif defined(__DOS__) #elif defined(__DOS__)
# error NOT IMPLEMENTED # error NOT IMPLEMENTED
#else #else
# include <sys/types.h> # include "../cmn/syscall.h"
# include <sys/stat.h>
# include <dirent.h> # include <dirent.h>
# include <errno.h> # include <errno.h>
#endif #endif
@ -487,7 +486,7 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir)
info_t* info; info_t* info;
struct dirent* ent; struct dirent* ent;
int x; int x;
#if defined(HAVE_LSTAT64) #if defined(QSE_LSTAT64)
struct stat64 st; struct stat64 st;
#else #else
struct stat st; struct stat st;
@ -526,11 +525,11 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir)
return QSE_NULL; return QSE_NULL;
} }
#if defined(HAVE_LSTAT64) #if defined(QSE_LSTAT64)
x = lstat64 (mfname, &st); x = QSE_LSTAT64 (mfname, &st);
#else #else
x = lstat (mfname, &st); x = QSE_LSTAT (mfname, &st);
#endif #endif
QSE_MMGR_FREE (dir->mmgr, mfname); QSE_MMGR_FREE (dir->mmgr, mfname);
@ -542,16 +541,15 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir)
if (set_entry_name (dir, ent->d_name) <= -1) return QSE_NULL; if (set_entry_name (dir, ent->d_name) <= -1) return QSE_NULL;
if (S_ISDIR(st.st_mode))
{ dir->ent.size = st.st_size;
dir->ent.size = 0;
dir->ent.type = QSE_DIR_ENT_DIRECTORY; #define IS_TYPE(st,type) ((st.st_mode & S_IFMT) == S_IFDIR)
} dir->ent.type = IS_TYPE(st,S_IFDIR)? QSE_DIR_ENT_DIR:
else IS_TYPE(st,S_IFCHR)? QSE_DIR_ENT_CHAR:
{ IS_TYPE(st,S_IFBLK)? QSE_DIR_ENT_BLOCK:
dir->ent.size = st.st_size; QSE_DIR_ENT_UNKNOWN;
dir->ent.type = QSE_DIR_ENT_UNKNOWN;
}
#endif #endif

View File

@ -39,7 +39,6 @@ static void list (qse_dir_t* dir, const qse_char_t* name)
int dir_main (int argc, qse_char_t* argv[]) int dir_main (int argc, qse_char_t* argv[])
{ {
int n;
qse_dir_t* dir; qse_dir_t* dir;
if (argc != 2) if (argc != 2)
@ -59,7 +58,7 @@ int dir_main (int argc, qse_char_t* argv[])
list (dir, QSE_T("..")); list (dir, QSE_T(".."));
qse_dir_close (dir); qse_dir_close (dir);
return n; return 0;
} }
int qse_main (int argc, qse_achar_t* argv[]) int qse_main (int argc, qse_achar_t* argv[])