mail[Wesnoth-commits] r27144 - in /trunk/src: filesystem.cpp filesystem.hpp game.cpp


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

Header


Content

Posted by cycholka on June 13, 2008 - 11:42:
Author: cycholka
Date: Fri Jun 13 11:42:39 2008
New Revision: 27144

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27144&view=rev
Log:
Revert commit #27137 due to two serious issues mentioned on the tracker

Modified:
    trunk/src/filesystem.cpp
    trunk/src/filesystem.hpp
    trunk/src/game.cpp

Modified: trunk/src/filesystem.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/filesystem.cpp?rev=27144&r1=27143&r2=27144&view=diff
==============================================================================
--- trunk/src/filesystem.cpp (original)
+++ trunk/src/filesystem.cpp Fri Jun 13 11:42:39 2008
@@ -28,8 +28,6 @@
 
 #ifdef _WIN32
 #include "filesystem_win32.ii"
-#include <shlobj.h>
-#include "SDL_syswm.h"
 #else /* !_WIN32 */
 #include <unistd.h>
 #include <dirent.h>
@@ -406,83 +404,35 @@
        }
 }
 
-namespace {
-// stuff for local userdata
-bool use_local_userdata = false;
-bool userdata_status_inited = false;
-}
-
-void set_local_userdata(bool use_local)
-{
-       use_local_userdata = use_local;
-       userdata_status_inited = true;
-}
-
 std::string get_user_data_dir()
 {
 #ifdef _WIN32
+
        static bool inited_dirs = false;
-       char buf[MAX_PATH + 1];
-       if(use_local_userdata) {
-        // use local
-               if(!inited_dirs) {
-                       _mkdir("userdata");
-                       _mkdir("userdata/editor");
-                       _mkdir("userdata/editor/maps");
-                       _mkdir("userdata/data");
-                       _mkdir("userdata/data/ais");
-                       _mkdir("userdata/data/campaigns");
-                       _mkdir("userdata/data/multiplayer");
-                       _mkdir("userdata/data/maps");
-                       _mkdir("userdata/data/maps/multiplayer");
-                       _mkdir("userdata/data/units");
-                       _mkdir("userdata/saves");
-                       inited_dirs = true;
-               }
-               const char* const res = getcwd(buf,sizeof(buf));
-
-               if(res != NULL) {
-                       std::string cur_path(res);
-                       
std::replace(cur_path.begin(),cur_path.end(),'\\','/');
-                       return cur_path + "/userdata";
-               } else {
-                       return "userdata";
-               }
+
+       if(!inited_dirs) {
+               _mkdir("userdata");
+               _mkdir("userdata/editor");
+               _mkdir("userdata/editor/maps");
+               _mkdir("userdata/data");
+               _mkdir("userdata/data/ais");
+               _mkdir("userdata/data/campaigns");
+               _mkdir("userdata/data/multiplayer");
+               _mkdir("userdata/data/maps");
+               _mkdir("userdata/data/maps/multiplayer");
+               _mkdir("userdata/saves");
+               inited_dirs = true;
+       }
+
+       char buf[256];
+       const char* const res = getcwd(buf,sizeof(buf));
+
+       if(res != NULL) {
+               std::string cur_path(res);
+               std::replace(cur_path.begin(),cur_path.end(),'\\','/');
+               return cur_path + "/userdata";
        } else {
-               // use per-user folder
-               SDL_SysWMinfo wmInfo;
-
-               SDL_GetWMInfo(&wmInfo); // need some handle for win api
-               if (SHGetSpecialFolderPath(wmInfo.window, buf, 
CSIDL_PERSONAL, true)) {
-                       // CSIDL_PERSONAL === My Documents
-                       std::string usr_path(buf);
-                       LOG_FS << "Retrieved Windows user directory: " << 
usr_path << "\n";
-                       
std::replace(usr_path.begin(),usr_path.end(),'\\','/');
-                       if(usr_path.empty()) {
-                               // fallback to local if something didn't work
-                               return "userdata";
-                       } else {
-                               // all OK
-                               usr_path += "/Wesnoth/";
-                               usr_path += VERSION;
-                               // sort userdata by version
-                               if(!inited_dirs) {
-                                       _mkdir(usr_path.c_str());
-                                       _mkdir((usr_path + 
"/editor").c_str());
-                                       _mkdir((usr_path + 
"/editor/maps").c_str());
-                                       _mkdir((usr_path + "/data").c_str());
-                                       _mkdir((usr_path + 
"/data/ais").c_str());
-                                       _mkdir((usr_path + 
"/data/campaigns").c_str());
-                                       _mkdir((usr_path + 
"/data/multiplayer").c_str());
-                                       _mkdir((usr_path + 
"/data/maps").c_str());
-                                       _mkdir((usr_path + 
"/data/maps/multiplayer").c_str());
-                                       _mkdir((usr_path + 
"/data/units").c_str());
-                                       _mkdir((usr_path + "/saves").c_str());
-                                       inited_dirs = true;
-                               }
-                               return usr_path;
-                       }
-               }
+               return "userdata";
        }
 #elif defined(__BEOS__)
        if (be_path.InitCheck() != B_OK) {
@@ -533,7 +483,6 @@
                mkdir((dir_path + "/data/multiplayer").c_str(),AccessMode);
                mkdir((dir_path + "/data/maps").c_str(),AccessMode);
                mkdir((dir_path + 
"/data/maps/multiplayer").c_str(),AccessMode);
-               mkdir((dir_path + "/data/units").c_str(),AccessMode);
                mkdir((dir_path + "/saves").c_str(),AccessMode);
                if(res == 0) {
                        dir = opendir(dir_path.c_str());

Modified: trunk/src/filesystem.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/filesystem.hpp?rev=27144&r1=27143&r2=27144&view=diff
==============================================================================
--- trunk/src/filesystem.hpp (original)
+++ trunk/src/filesystem.hpp Fri Jun 13 11:42:39 2008
@@ -82,11 +82,6 @@
 
 bool make_directory(const std::string& dirname);
 bool delete_directory(const std::string& dirname);
-
-//! Sets whether a "userdata" dir located in the working path
-//! should be used instead of per-user directories in Windows.
-//! This has no effect on other systems.
-void set_local_userdata(bool use_local);
 
 // Basic disk I/O:
 

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=27144&r1=27143&r2=27144&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Fri Jun 13 11:42:39 2008
@@ -314,13 +314,7 @@
                } else if (val.substr(0, 6) == "--log-") {
                } else if(val == "--nosound") {
                        no_sound = true;
-               }
-#ifdef _WIN32
-               else if(val == "--local-userdir") {
-                       // redundant but it must be recognized...
-               }
-#endif /* _WIN32 */
-               else if(val == "--new-widgets") {
+               } else if(val == "--new-widgets") {
                        // This is a hidden option to enable the new widget 
toolkit.
                        gui2::new_widgets = true;
                } else if(val[0] == '-') {
@@ -2337,11 +2331,6 @@
                        << "                               by id.\n"
                        << "  --turns=value                sets the number of 
turns. The default is \"50\".\n"
                        << "  --exit-at-end                exit Wesnoth at 
end of scenario.\n"
-#ifdef _WIN32
-                       << "  --local-userdir              Windows only: use 
directory \"userdata\" in the\n"
-                       << "                               working path 
instead of per-user\n"
-                       << "                               \"My 
Documents\\Wesnoth\"\n"
-#endif
                        << "  --new-widgets                there is a new WIP 
widget toolkit this switch enables the new toolkit\n"
                        << "                               (VERY EXPERIMENTAL 
don't file bug reports since most are known).\n"
                        ;
@@ -2459,11 +2448,7 @@
                        std::cout << lg::list_logdomains() << "\n";
                        return 0;
                }
-#ifdef _WIN32
-               else if(val == "--local-userdir") {
-                       set_local_userdata(true);
-               }
-#endif /* _WIN32 */
+
        }
 
        srand(time(NULL));




Related Messages


Powered by MHonArc, Updated Fri Jun 13 12:01:53 2008