Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79691 - trunk/tools/build/v2/engine
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-23 03:26:03


Author: jurko
Date: 2012-07-23 03:26:02 EDT (Mon, 23 Jul 2012)
New Revision: 79691
URL: http://svn.boost.org/trac/boost/changeset/79691

Log:
Updated the Windows Boost Build implementation to use direct Windows APIs instead of the Windows POSIX layer & standard C library functionality for collecting information about files. Now returns file timestamps with much better precision than 1 second.
Text files modified:
   trunk/tools/build/v2/engine/filent.c | 53 +++++++++++++++++++++++----------------
   trunk/tools/build/v2/engine/filesys.c | 12 +++++++++
   2 files changed, 43 insertions(+), 22 deletions(-)

Modified: trunk/tools/build/v2/engine/filent.c
==============================================================================
--- trunk/tools/build/v2/engine/filent.c (original)
+++ trunk/tools/build/v2/engine/filent.c 2012-07-23 03:26:02 EDT (Mon, 23 Jul 2012)
@@ -83,10 +83,17 @@
         string_append( pathspec, "*" );
     }
 
+ /* The following code for collecting information about all files in a folder
+ * needs to be synchronized with how the file_query() operation is
+ * implemented (collects information about a single file).
+ */
     {
- struct _finddata_t finfo;
- long const handle = _findfirst( pathspec->value, &finfo );
- if ( handle < 0L )
+ /* FIXME: Avoid duplicate FindXXX Windows API calls here and in the code
+ * determining a normalized path.
+ */
+ WIN32_FIND_DATA finfo;
+ HANDLE const findHandle = FindFirstFileA( pathspec->value, &finfo );
+ if ( findHandle == INVALID_HANDLE_VALUE )
         {
             string_free( pathspec );
             return -1;
@@ -97,8 +104,8 @@
         {
             OBJECT * pathname_obj;
 
- f.f_base.ptr = finfo.name;
- f.f_base.len = strlen( finfo.name );
+ f.f_base.ptr = finfo.cFileName;
+ f.f_base.len = strlen( finfo.cFileName );
             string_truncate( pathname, 0 );
             path_build( &f, pathname );
 
@@ -107,14 +114,14 @@
             files = list_push_back( files, pathname_obj );
             {
                 file_info_t * const ff = file_info( pathname_obj );
- ff->is_dir = finfo.attrib & _A_SUBDIR ? 1 : 0;
+ ff->is_dir = finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
                 ff->is_file = !ff->is_dir;
- timestamp_init( &ff->time, finfo.time_write, 0 );
+ timestamp_from_filetime( &ff->time, &finfo.ftLastWriteTime );
             }
         }
- while ( !_findnext( handle, &finfo ) );
+ while ( FindNextFile( findHandle, &finfo ) );
 
- _findclose( handle );
+ FindClose( findHandle );
     }
 
     string_free( pathname );
@@ -176,23 +183,25 @@
 
 /*
  * file_query_() - query information about a path from the OS
+ *
+ * The following code for collecting information about a single file needs to be
+ * synchronized with how the file_collect_dir_content_() operation is
+ * implemented (collects information about all files in a folder).
  */
 
 int file_query_( file_info_t * const info )
 {
- /* Note that the POSIX stat() function implementation on Windows suffers
- * from several issues:
- * * Does not support file timestamps with resolution finer than 1 second.
- * This means it can not be used to detect file timestamp changes of
- * less than one second. One possible consequence is that some
- * fast-paced touch commands (such as those done by Boost Build's
- * internal testing system if it does not do extra waiting before those
- * touch operations) will not be detected correctly by the build system.
- * * Returns file modification times automatically adjusted for daylight
- * savings time even though daylight savings time should have nothing to
- * do with internal time representation.
- */
- return file_query_posix_( info );
+ WIN32_FILE_ATTRIBUTE_DATA fileData;
+ char const * const pathstr = object_str( info->name );
+ char const * const pathspec = *pathstr ? pathstr : ".";
+
+ if ( !GetFileAttributesExA( pathspec, GetFileExInfoStandard, &fileData ) )
+ return -1;
+
+ info->is_dir = fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ info->is_file = !info->is_dir;
+ timestamp_from_filetime( &info->time, &fileData.ftLastWriteTime );
+ return 0;
 }
 
 

Modified: trunk/tools/build/v2/engine/filesys.c
==============================================================================
--- trunk/tools/build/v2/engine/filesys.c (original)
+++ trunk/tools/build/v2/engine/filesys.c 2012-07-23 03:26:02 EDT (Mon, 23 Jul 2012)
@@ -214,6 +214,18 @@
  * file_query_posix_() - query information about a path using POSIX stat()
  *
  * Fallback file_query_() implementation for OS specific modules.
+ *
+ * Note that the Windows POSIX stat() function implementation suffers from
+ * several issues:
+ * * Does not support file timestamps with resolution finer than 1 second,
+ * meaning it can not be used to detect file timestamp changes of less than
+ * 1 second. One possible consequence is that some fast-paced touch commands
+ * (such as those done by Boost Build's internal testing system if it does
+ * not do some extra waiting) will not be detected correctly by the build
+ * system.
+ * * Returns file modification times automatically adjusted for daylight
+ * savings time even though daylight savings time should have nothing to do
+ * with internal time representation.
  */
 
 int file_query_posix_( file_info_t * const info )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk