mail[Wesnoth-commits] r33440 - /trunk/src/preferences.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by thomas . baumhauer on March 08, 2009 - 17:48:
Author: baufo
Date: Sun Mar  8 17:48:17 2009
New Revision: 33440

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33440&view=rev
Log:
only set permissions of preferences file upon creation

Modified:
    trunk/src/preferences.cpp

Modified: trunk/src/preferences.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences.cpp?rev=33440&r1=33439&r2=33440&view=diff
==============================================================================
--- trunk/src/preferences.cpp (original)
+++ trunk/src/preferences.cpp Sun Mar  8 17:48:17 2009
@@ -65,6 +65,12 @@
 
 void write_preferences()
 {
+    #ifndef _WIN32
+
+    bool prefs_file_existed = access(get_prefs_file().c_str(), F_OK) == 0;
+
+    #endif
+
        try {
                scoped_ostream prefs_file = ostream_file(get_prefs_file());
                write(*prefs_file, prefs);
@@ -75,8 +81,12 @@
 
     #ifndef _WIN32
 
-    if(chmod(get_prefs_file().c_str(), 0600) == -1) {
-        std::cerr << "error setting permissions of preferences file '" << 
get_prefs_file() << "'\n";
+    if(!prefs_file_existed) {
+
+        if(chmod(get_prefs_file().c_str(), 0600) == -1) {
+            std::cerr << "error setting permissions of preferences file '" 
<< get_prefs_file() << "'\n";
+        }
+
     }
 
     #endif




Related Messages


Powered by MHonArc, Updated Sun Mar 08 18:00:28 2009