From 5cd5041ed3a56bd9ecdee4c8fd2f173b61a9d0ae Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 19 Oct 2011 22:29:28 +0000 Subject: [PATCH] added QSE_FIO_NOFOLLOW --- qse/configure | 288 +++++++++++++++++++++++++++++++++--- qse/configure.ac | 4 +- qse/include/qse/cmn/fio.h | 6 + qse/include/qse/cmn/path.h | 11 ++ qse/include/qse/cmn/sio.h | 1 + qse/include/qse/config.h.in | 21 +++ qse/lib/cmn/fio.c | 7 + qse/lib/fs/dir.c | 28 +++- 8 files changed, 341 insertions(+), 25 deletions(-) diff --git a/qse/configure b/qse/configure index 404bc4ff..090e3aaa 100755 --- a/qse/configure +++ b/qse/configure @@ -2182,6 +2182,63 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval "test \"\${$4+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_member + # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes @@ -5698,13 +5755,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:5701: $ac_compile\"" >&5) + (eval echo "\"\$as_me:5758: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:5704: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:5761: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:5707: output\"" >&5) + (eval echo "\"\$as_me:5764: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6899,7 +6956,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6902 "configure"' > conftest.$ac_ext + echo '#line 6959 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8955,11 +9012,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8958: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9015: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8962: \$? = $ac_status" >&5 + echo "$as_me:9019: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9294,11 +9351,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9297: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9354: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9301: \$? = $ac_status" >&5 + echo "$as_me:9358: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9399,11 +9456,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9402: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9459: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9406: \$? = $ac_status" >&5 + echo "$as_me:9463: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9454,11 +9511,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9457: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9514: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9461: \$? = $ac_status" >&5 + echo "$as_me:9518: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11838,7 +11895,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11841 "configure" +#line 11898 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11934,7 +11991,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11937 "configure" +#line 11994 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13890,11 +13947,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13893: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13950: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13897: \$? = $ac_status" >&5 + echo "$as_me:13954: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13989,11 +14046,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13992: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14049: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13996: \$? = $ac_status" >&5 + echo "$as_me:14053: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14041,11 +14098,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14044: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14101: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14048: \$? = $ac_status" >&5 + echo "$as_me:14105: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15400,7 +15457,7 @@ _ACEOF fi done -for ac_func in lseek64 stat64 fstat64 ftruncate64 +for ac_func in lseek64 stat64 fstat64 lstat64 ftruncate64 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -15500,6 +15557,195 @@ done LIBS="$OLDLIBS" +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 +$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } +if eval "test \"\${$as_ac_Header+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_ac_Header=yes" +else + eval "$as_ac_Header=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_ac_Header + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if test "${ac_cv_search_opendir+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then : + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if test "${ac_cv_search_opendir+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then : + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + + + + ac_fn_c_check_member "$LINENO" "struct dirent" "d_type" "ac_cv_member_struct_dirent_d_type" " +#include +#ifdef HAVE_DIRENT_H +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif +# ifdef HAVE_SYS_DIR_H +# include +# endif +# ifdef HAVE_NDIR_H +# include +# endif +#endif + +" +if test "x$ac_cv_member_struct_dirent_d_type" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_DIRENT_D_TYPE 1 +_ACEOF + + +fi + + + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. diff --git a/qse/configure.ac b/qse/configure.ac index 2080ade1..e7a03f8d 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -95,7 +95,7 @@ AC_CHECK_FUNCS([mbrlen mbrtowc wcrtomb]) AC_CHECK_FUNCS([mbsnrtowcs mbsrtowcs wcsnrtombs wcsrtombs]) AC_CHECK_FUNCS([wctype iswctype wctrans towctrans]) AC_CHECK_FUNCS([isblank iswblank]) -AC_CHECK_FUNCS([lseek64 stat64 fstat64 ftruncate64]) +AC_CHECK_FUNCS([lseek64 stat64 fstat64 lstat64 ftruncate64]) AC_CHECK_FUNCS([timegm timelocal]) AC_CHECK_FUNCS([utime utimes]) AC_CHECK_FUNCS([sysconf]) @@ -108,6 +108,8 @@ AC_CHECK_FUNCS([pow fmod sin cos tan atan atan2 log exp sqrt]) AC_CHECK_FUNCS([powf fmodf sinf cosf tanf atanf atan2f logf expf sqrtf]) LIBS="$OLDLIBS" +AC_STRUCT_DIRENT_D_TYPE + dnl check the size of primitive data types AC_CHECK_SIZEOF(char,,[[]]) AC_CHECK_SIZEOF(short,,[[]]) diff --git a/qse/include/qse/cmn/fio.h b/qse/include/qse/cmn/fio.h index a371dd47..0b7e5d2a 100644 --- a/qse/include/qse/cmn/fio.h +++ b/qse/include/qse/cmn/fio.h @@ -42,6 +42,7 @@ enum qse_fio_open_flag_t /** don't close an I/O handle in qse_fio_fini() and qse_fio_close() */ QSE_FIO_NOCLOSE = (1 << 4), + /* normal open flags */ QSE_FIO_READ = (1 << 8), QSE_FIO_WRITE = (1 << 9), QSE_FIO_APPEND = (1 << 10), @@ -50,10 +51,15 @@ enum qse_fio_open_flag_t QSE_FIO_TRUNCATE = (1 << 12), QSE_FIO_EXCLUSIVE = (1 << 13), QSE_FIO_SYNC = (1 << 14), + + /* do not follow a symbolic link, only on a supported platform */ + QSE_FIO_NOFOLLOW = (1 << 15), /* for WIN32 only. harmless(no effect) when used on other platforms */ QSE_FIO_NOSHRD = (1 << 24), QSE_FIO_NOSHWR = (1 << 25), + + /* for WIN32 only. harmless(no effect) when used on other platforms */ QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */ QSE_FIO_SEQUENTIAL = (1 << 27) /* hint that access is sequential */ }; diff --git a/qse/include/qse/cmn/path.h b/qse/include/qse/cmn/path.h index bc4fbe8c..afbdefad 100644 --- a/qse/include/qse/cmn/path.h +++ b/qse/include/qse/cmn/path.h @@ -59,6 +59,17 @@ const qse_wchar_t* qse_wcsbasename ( const qse_wchar_t* path ); +/** + * The qse_isabspath() function determines if a path name is absolute. + * A path name beginning with a segment separator is absolute. + * On Win32/OS2/DOS, it also returns 1 if a path name begins with a drive + * letter followed by a colon. + * @return 1 if absolute, 0 if not. + */ +int qse_isabspath ( + const qse_char_t* path +); + /** * The qse_canonpath() function canonicalizes a path name @a path by deleting * unnecessary path segments from it and stores the result to a memory buffer diff --git a/qse/include/qse/cmn/sio.h b/qse/include/qse/cmn/sio.h index 2b0267dc..8a7705ff 100644 --- a/qse/include/qse/cmn/sio.h +++ b/qse/include/qse/cmn/sio.h @@ -44,6 +44,7 @@ enum qse_sio_open_flag_t QSE_SIO_TRUNCATE = QSE_FIO_TRUNCATE, QSE_SIO_EXCLUSIVE = QSE_FIO_EXCLUSIVE, QSE_SIO_SYNC = QSE_FIO_SYNC, + QSE_SIO_NOFOLLOW = QSE_FIO_NOFOLLOW, QSE_SIO_NOSHRD = QSE_FIO_NOSHRD, QSE_SIO_NOSHWR = QSE_FIO_NOSHWR diff --git a/qse/include/qse/config.h.in b/qse/include/qse/config.h.in index 812506d4..bbb11e7a 100644 --- a/qse/include/qse/config.h.in +++ b/qse/include/qse/config.h.in @@ -36,6 +36,10 @@ /* Define to 1 if you have the `cosl' function. */ #undef HAVE_COSL +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -93,6 +97,9 @@ /* Define to 1 if you have the `lseek64' function. */ #undef HAVE_LSEEK64 +/* Define to 1 if you have the `lstat64' function. */ +#undef HAVE_LSTAT64 + /* Define to 1 if you have the `mbrlen' function. */ #undef HAVE_MBRLEN @@ -108,6 +115,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW @@ -165,9 +175,20 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if `d_type' is a member of `struct dirent'. */ +#undef HAVE_STRUCT_DIRENT_D_TYPE + /* Define to 1 if you have the `sysconf' function. */ #undef HAVE_SYSCONF +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H diff --git a/qse/lib/cmn/fio.c b/qse/lib/cmn/fio.c index 534b13e1..bd129601 100644 --- a/qse/lib/cmn/fio.c +++ b/qse/lib/cmn/fio.c @@ -147,6 +147,9 @@ int qse_fio_init ( if (flags & QSE_FIO_SYNC) flag_and_attr |= FILE_FLAG_WRITE_THROUGH; + if (flags & QSE_FIO_NOFOLLOW) + flag_and_attr |= FILE_FLAG_OPEN_REPARSE_POINT; + /* these two are just hints to OS */ if (flags & QSE_FIO_RANDOM) flag_and_attr |= FILE_FLAG_RANDOM_ACCESS; @@ -350,6 +353,10 @@ int qse_fio_init ( if (flags & QSE_FIO_EXCLUSIVE) desired_access |= O_EXCL; if (flags & QSE_FIO_SYNC) desired_access |= O_SYNC; + #if defined(O_NOFOLLOW) + if (flags & QSE_FIO_NOFOLLOW) desired_access |= O_NOFOLLOW; + #endif + #if defined(O_LARGEFILE) desired_access |= O_LARGEFILE; #endif diff --git a/qse/lib/fs/dir.c b/qse/lib/fs/dir.c index 83cc5907..1adb4272 100644 --- a/qse/lib/fs/dir.c +++ b/qse/lib/fs/dir.c @@ -31,6 +31,7 @@ # error NOT IMPLEMENTED #else # include +# include # include #endif @@ -383,6 +384,25 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir) return QSE_NULL; } +#if defined(HAVE_STRUCT_DIRENT_D_TYPE) + if (ent->d_type != DT_DIR) +#endif + { + int x; + #if defined(HAVE_LSTAT64) + struct stat64 st; + x = lstat64 (ent->d_name, &st); + #else + struct stat st; + x = lstat (ent->d_name, &st); + #endif + if (x == -1) + { + /*TODO: dir->errnum = ... */ + return QSE_NULL; + } + } + if (set_entry_name (dir, ent->d_name) <= -1) return QSE_NULL; #if defined(HAVE_STRUCT_DIRENT_D_TYPE) @@ -393,15 +413,17 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir) dir->ent.type = QSE_DIR_ENT_DIRECTORY; break; + case DT_REG: + dir->ent.type = QSE_DIR_ENT_REGULAR; + break; + default: dir->ent.size = 0; dir->ent.type = QSE_DIR_ENT_UNKNOWN; break; } - - #else - /* call lstat??? */ #endif + #endif return &dir->ent; }