[Cmake-commits] [cmake-commits] david.cole committed SystemTools.cxx 1.231 1.232 SystemTools.hxx.in 1.74 1.75

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Dec 18 10:43:26 EST 2008


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv30487/kwsys

Modified Files:
	SystemTools.cxx SystemTools.hxx.in 
Log Message:
BUG: Do not copy permissions of files when making the copy in an install rule. If the source file was read-only, this prevents the subsequent set of the destination file's modification time, making the copied file always different in time-stamp than the original and always installing a new file with a new time stamp (but the same content) causing unnecessary downstream incremental rebuilds. As part of this fix, add an optional copyPermissions parameter to the SystemTools routines CopyFileIfDifferent, CopyFileAlways, CopyAFile and CopyADirectory. The copyPermissions parameter defaults to true to preserve the behavior of these routines for existing callers.


Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.231
retrieving revision 1.232
diff -C 2 -d -r1.231 -r1.232
*** SystemTools.cxx	16 Oct 2008 23:30:49 -0000	1.231
--- SystemTools.cxx	18 Dec 2008 15:43:23 -0000	1.232
***************
*** 1612,1616 ****
  
  bool SystemTools::CopyFileIfDifferent(const char* source,
!                                       const char* destination)
  {
    // special check for a destination that is a directory
--- 1612,1617 ----
  
  bool SystemTools::CopyFileIfDifferent(const char* source,
!                                       const char* destination,
!                                       bool copyPermissions)
  {
    // special check for a destination that is a directory
***************
*** 1625,1629 ****
      if(SystemTools::FilesDiffer(source, new_destination.c_str()))
        {
!       return SystemTools::CopyFileAlways(source, destination);
        }
      else
--- 1626,1631 ----
      if(SystemTools::FilesDiffer(source, new_destination.c_str()))
        {
!       return SystemTools::CopyFileAlways(source, destination,
!                                          copyPermissions);
        }
      else
***************
*** 1638,1642 ****
    if(SystemTools::FilesDiffer(source, destination))
      {
!     return SystemTools::CopyFileAlways(source, destination);
      }
    // at this point the files must be the same so return true
--- 1640,1644 ----
    if(SystemTools::FilesDiffer(source, destination))
      {
!     return SystemTools::CopyFileAlways(source, destination, copyPermissions);
      }
    // at this point the files must be the same so return true
***************
*** 1719,1726 ****
  
  
  /**
   * Copy a file named by "source" to the file named by "destination".
   */
! bool SystemTools::CopyFileAlways(const char* source, const char* destination)
  {
    // If files are the same do not copy
--- 1721,1730 ----
  
  
+ //----------------------------------------------------------------------------
  /**
   * Copy a file named by "source" to the file named by "destination".
   */
! bool SystemTools::CopyFileAlways(const char* source, const char* destination,
!                                  bool copyPermissions)
  {
    // If files are the same do not copy
***************
*** 1825,1829 ****
     return false;
      }
!   if ( perms )
      {
      if ( !SystemTools::SetPermissions(destination, perm) )
--- 1829,1833 ----
     return false;
      }
!   if ( copyPermissions && perms )
      {
      if ( !SystemTools::SetPermissions(destination, perm) )
***************
*** 1837,1849 ****
  //----------------------------------------------------------------------------
  bool SystemTools::CopyAFile(const char* source, const char* destination,
!                             bool always)
  {
    if(always)
      {
!     return SystemTools::CopyFileAlways(source, destination);
      }
    else
      {
!     return SystemTools::CopyFileIfDifferent(source, destination);
      }
  }
--- 1841,1853 ----
  //----------------------------------------------------------------------------
  bool SystemTools::CopyAFile(const char* source, const char* destination,
!                             bool always, bool copyPermissions)
  {
    if(always)
      {
!     return SystemTools::CopyFileAlways(source, destination, copyPermissions);
      }
    else
      {
!     return SystemTools::CopyFileIfDifferent(source, destination, copyPermissions);
      }
  }
***************
*** 1854,1858 ****
   */
  bool SystemTools::CopyADirectory(const char* source, const char* destination,
!                                  bool always)
  {
    Directory dir;
--- 1858,1862 ----
   */
  bool SystemTools::CopyADirectory(const char* source, const char* destination,
!                                  bool always, bool copyPermissions)
  {
    Directory dir;
***************
*** 1878,1882 ****
          if (!SystemTools::CopyADirectory(fullPath.c_str(),
                                           fullDestPath.c_str(),
!                                          always))
            {
            return false;
--- 1882,1887 ----
          if (!SystemTools::CopyADirectory(fullPath.c_str(),
                                           fullDestPath.c_str(),
!                                          always,
!                                          copyPermissions))
            {
            return false;
***************
*** 1885,1889 ****
        else
          {
!         if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always))
            {
            return false;
--- 1890,1895 ----
        else
          {
!         if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always,
!                                    copyPermissions))
            {
            return false;

Index: SystemTools.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.hxx.in,v
retrieving revision 1.74
retrieving revision 1.75
diff -C 2 -d -r1.74 -r1.75
*** SystemTools.hxx.in	27 May 2008 18:47:00 -0000	1.74
--- SystemTools.hxx.in	18 Dec 2008 15:43:24 -0000	1.75
***************
*** 491,504 ****
    /**
     * Copy the source file to the destination file only
!    * if the two files differ.  
     */
    static bool CopyFileIfDifferent(const char* source,
!                                   const char* destination);
!   
    /**
     * Compare the contents of two files.  Return true if different
     */
    static bool FilesDiffer(const char* source, const char* destination);
!   
    /**
     * Return true if the two files are the same file
--- 491,508 ----
    /**
     * Copy the source file to the destination file only
!    * if the two files differ. If the "copyPermissions"
!    * argument is true, the permissions of the copy are
!    * set to be the same as the permissions of the
!    * original.
     */
    static bool CopyFileIfDifferent(const char* source,
!                                   const char* destination,
!                                   bool copyPermissions = true);
! 
    /**
     * Compare the contents of two files.  Return true if different
     */
    static bool FilesDiffer(const char* source, const char* destination);
! 
    /**
     * Return true if the two files are the same file
***************
*** 507,521 ****
  
    /**
!    * Copy a file
     */
!   static bool CopyFileAlways(const char* source, const char* destination);
  
    /**
     * Copy a file.  If the "always" argument is true the file is always
     * copied.  If it is false, the file is copied only if it is new or
!    * has changed.
     */
    static bool CopyAFile(const char* source, const char* destination,
!                         bool always = true);
  
    /**
--- 511,530 ----
  
    /**
!    * Copy a file. If the "copyPermissions" argument is true, the
!    * permissions of the copy are set to be the same as the permissions
!    * of the original.
     */
!   static bool CopyFileAlways(const char* source, const char* destination,
!                              bool copyPermissions = true);
  
    /**
     * Copy a file.  If the "always" argument is true the file is always
     * copied.  If it is false, the file is copied only if it is new or
!    * has changed. If the "copyPermissions" argument is true, the
!    * permissions of the copy are set to be the same as the permissions
!    * of the original.
     */
    static bool CopyAFile(const char* source, const char* destination,
!                         bool always = true, bool copyPermissions = true);
  
    /**
***************
*** 526,530 ****
     */
    static bool CopyADirectory(const char* source, const char* destination,
!                              bool always = true);
    
    /**
--- 535,539 ----
     */
    static bool CopyADirectory(const char* source, const char* destination,
!                              bool always = true, bool copyPermissions = true);
    
    /**



More information about the Cmake-commits mailing list