Переглянути джерело

Merge branch 'file-write-umask'

Brad King 15 роки тому
батько
коміт
efffb7b979
2 змінених файлів з 18 додано та 24 видалено
  1. 9 12
      Source/cmFileCommand.cxx
  2. 9 12
      Source/cmWriteFileCommand.cxx

+ 9 - 12
Source/cmFileCommand.cxx

@@ -183,24 +183,18 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
   std::string dir = cmSystemTools::GetFilenamePath(fileName);
   cmSystemTools::MakeDirectory(dir.c_str());
 
-  mode_t mode =
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-    S_IREAD | S_IWRITE
-#elif defined( __BORLANDC__ )
-    S_IRUSR | S_IWUSR
-#else
-    0666
-#endif
-    ;
+  mode_t mode = 0;
 
   // Set permissions to writable
   if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
     {
     cmSystemTools::SetPermissions(fileName.c_str(),
 #if defined( _MSC_VER ) || defined( __MINGW32__ )
-      S_IREAD | S_IWRITE
+      mode | S_IWRITE
+#elif defined( __BORLANDC__ )
+      mode | S_IWUSR
 #else
-      0666
+      mode | S_IWUSR | S_IWGRP
 #endif
     );
     }
@@ -217,7 +211,10 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
     }
   file << message;
   file.close();
-  cmSystemTools::SetPermissions(fileName.c_str(), mode);
+  if(mode)
+    {
+    cmSystemTools::SetPermissions(fileName.c_str(), mode);
+    }
   return true;
 }
 

+ 9 - 12
Source/cmWriteFileCommand.cxx

@@ -54,24 +54,18 @@ bool cmWriteFileCommand
   std::string dir = cmSystemTools::GetFilenamePath(fileName);
   cmSystemTools::MakeDirectory(dir.c_str());
 
-  mode_t mode =
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-    S_IREAD | S_IWRITE
-#elif defined( __BORLANDC__ )
-    S_IRUSR | S_IWUSR
-#else
-    0666
-#endif
-    ;
+  mode_t mode = 0;
 
   // Set permissions to writable
   if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
     {
     cmSystemTools::SetPermissions(fileName.c_str(),
 #if defined( _MSC_VER ) || defined( __MINGW32__ )
-      S_IREAD | S_IWRITE
+      mode | S_IWRITE
+#elif defined( __BORLANDC__ )
+      mode | S_IWUSR
 #else
-      0666
+      mode | S_IWUSR | S_IWGRP
 #endif
     );
     }
@@ -89,7 +83,10 @@ bool cmWriteFileCommand
     }
   file << message << std::endl;
   file.close();
-  cmSystemTools::SetPermissions(fileName.c_str(), mode);
+  if(mode)
+    {
+    cmSystemTools::SetPermissions(fileName.c_str(), mode);
+    }
 
   return true;
 }