Store levels edited by the user in $HOME
authorMiriam Ruiz <miriam@debian.org>
Wed, 3 Dec 2008 11:09:40 +0000 (3 12:09 +0100)
committerMiriam Ruiz <miriam@debian.org>
Wed, 3 Dec 2008 11:09:40 +0000 (3 12:09 +0100)
src/mapedit.cpp

index 86abe2b..4fa11fd 100644 (file)
@@ -167,7 +167,21 @@ void CMapEditor::start_map_editor()
        int omx=0,omy=0,old_mouse_z;
        char str[2048];
        str[0] = '\0';
-       usprintf(str, "levels");
+
+       char *home = getenv("HOME");
+       if (home != NULL)
+       {
+               char dir[2048];
+               snprintf(dir, sizeof(dir), "%s/.kball", home);
+               mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+               snprintf(dir, sizeof(dir), "%s/.kball/levels", home);
+               mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+               usprintf(str, "%s/.kball/levels/", home);
+       }
+       else
+       {
+               usprintf(str, "levels");
+       }
 
        mtracer.add("CMapEditor::start_map_editor()");