Changeset 2702 for trunk/src/kmk/dir.c


Ignore:
Timestamp:
Nov 21, 2013, 1:11:08 AM (12 years ago)
Author:
bird
Message:

kmk/WindowsNT: Avoiding unnecessary stat() calls. Reimplemented stat(), lstat(), fstat(), opendir(), readdir(), and closedir() using native NT APIs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir.c

    r2591 r2702  
    121121
    122122#ifdef WINDOWS32
     123#include <Windows.h>
    123124#include "pathstuff.h"
    124125#endif
     
    244245# define FS_NTFS     0x2
    245246# define FS_UNKNOWN  0x4
     247# ifdef KMK
     248    time_t last_updated; /**< The last time the directory was re-read. */
     249# endif
    246250#else
    247251# ifdef VMS
     
    611615              dc->ctime = st.st_ctime;
    612616              dc->mtime = st.st_mtime;
     617# ifdef KMK
     618              dc->last_updated = time(NULL);
     619# endif
    613620
    614621              /*
     
    691698  struct dirent *d;
    692699#ifdef WINDOWS32
     700# ifndef KMK
    693701  struct stat st;
     702# endif
    694703  int rehash = 0;
    695704#endif
     
    745754  if (dir->dirstream == 0)
    746755    {
    747 #ifdef WINDOWS32
     756#if defined(WINDOWS32) && !defined(KMK)
    748757      /*
    749758       * Check to see if directory has changed since last read. FAT
     
    751760       * on directories (ugh!).
    752761       */
     762# ifdef KMK
     763      if (dir->path_key && time(NULL) > dc->last_updated + 2) /* KMK: Only recheck every 2 seconds. */
     764# else
    753765      if (dir->path_key)
     766# endif
    754767        {
    755768          if ((dir->fs_flags & FS_FAT) != 0)
     
    758771              rehash = 1;
    759772            }
     773# ifdef KMK
     774          else if (   birdStatModTimeOnly (dir->path_key, &st.st_mtim, 1) == 0
     775                   && st.st_mtime > dir->mtime)
     776# else
    760777          else if (stat (dir->path_key, &st) == 0 && st.st_mtime > dir->mtime)
     778# endif
    761779            {
    762780              /* reset date stamp to show most recent re-process.  */
     
    765783            }
    766784
     785
    767786          /* If it has been already read in, all done.  */
    768787          if (!rehash)
     
    773792          if (!dir->dirstream)
    774793            return 0;
     794# ifdef KMK
     795          dc->last_updated = time(NULL);
     796# endif
    775797        }
    776798      else
     
    14001422#endif
    14011423
     1424#ifdef KMK
     1425static int dir_exists_p (const char *dirname)
     1426{
     1427  if (file_exists_p (dirname))
     1428    {
     1429      struct directory *dir = find_directory (dirname);
     1430      if (dir != NULL && dir->contents && dir->contents->dirfiles.ht_vec != NULL)
     1431        return 1;
     1432    }
     1433  return 0;
     1434}
     1435#endif
     1436
    14021437void
    14031438dir_setup_glob (glob_t *gl)
     
    14091444#ifdef __EMX__ /* The FreeBSD implementation actually uses gl_lstat!! */
    14101445  gl->gl_lstat = local_stat;
     1446#endif
     1447#ifdef KMK
     1448  gl->gl_exists = file_exists_p;
     1449  gl->gl_isdir = dir_exists_p;
    14111450#endif
    14121451  /* We don't bother setting gl_lstat, since glob never calls it.
     
    14361475#endif /* CONFIG_WITH_ALLOC_CACHES */
    14371476}
     1477
Note: See TracChangeset for help on using the changeset viewer.