- Timestamp:
- Mar 10, 2005, 1:18:27 PM (20 years ago)
- Location:
- orxonox/branches/updater/src/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui.cc
r3379 r3469 95 95 96 96 // Reading Values from File 97 exec->set Filename("~/.orxonox.conf");97 exec->setConfFile("~/.orxonox/orxonox.conf"); 98 98 exec->readFromFile(orxonoxGUI); 99 99 // Merging changes to the Options from appended flags. -
orxonox/branches/updater/src/gui/orxonox_gui_exec.cc
r3464 r3469 25 25 26 26 #include "orxonox_gui_exec.h" 27 27 28 #include <iostream> 28 29 #include <string> 30 31 #include <sys/stat.h> 32 #include <sys/types.h> 33 29 34 30 35 HashTable* orxonoxFlagHash; … … 90 95 91 96 /** 97 \brief sets the confDir and File-name out of an input-string 98 */ 99 void OrxonoxGuiExec::setConfFile(char* confFile) 100 { 101 char splitter = 102 #ifdef __WIN32__ 103 '\\'; 104 #else 105 '/'; 106 #endif 107 char* tmpConfFile = new char[strlen(confFile)+1]; 108 strcpy(tmpConfFile, confFile); 109 char* tmp = strrchr(tmpConfFile, splitter); 110 if (tmp) 111 { 112 tmp[0] = '\0'; 113 this->setConfDir(tmpConfFile); 114 this->setFileName(tmp+1); 115 } 116 else 117 { 118 this->setConfDir("~/"); 119 this->setFileName(tmpConfFile); 120 } 121 delete []tmp; 122 delete []tmpConfFile; 123 } 124 125 /** 126 \brief sets the Directory of the configuration files 127 \param confDir the Directory for the configuration files 128 */ 129 void OrxonoxGuiExec::setConfDir(char* confDir) 130 { 131 if (!strncmp(confDir, "~/", 2)) 132 { 133 char tmp[500]; 134 #ifdef __WIN32__ 135 strcpy(tmp, getenv("USERPROFILE")); 136 #else 137 strcpy(tmp, getenv("HOME")); 138 #endif 139 this->confDir = new char[strlen(tmp)+strlen(confDir)]; 140 sprintf(this->confDir, "%s%s", tmp, confDir+1); 141 } 142 else 143 { 144 this->confDir = new char[strlen(confDir)+1]; 145 strcpy(this->confDir, confDir); 146 } 147 PRINTF(3)("Config Directory is: %s.\n", this->confDir); 148 mkdir(this->confDir, 0755); 149 } 150 151 /** 92 152 \brief Sets the location of the configuration File. 93 \param file name the location of the configFile153 \param fileName the location of the configFile 94 154 95 155 \todo: memory allocation could be better. … … 97 157 The name will be parsed from ~/ to /home/[username] on unix and c:/Documents and Settings/username/Settings/ on Windows 98 158 */ 99 void OrxonoxGuiExec::setFilename(char* filename) 100 { 101 char* buffer = (char*)malloc(2048*sizeof(char)); 102 sprintf(buffer, "%s", filename); 103 if(!strncmp(buffer, "~/", 2)) 104 { 105 #ifdef __WIN32__ 106 sprintf(configFile, "%s/%s", getenv("USERPROFILE"), buffer+2); 107 #else 108 sprintf(configFile, "%s/%s", getenv("HOME"), buffer+2); 109 #endif 110 } 111 else if(buffer) 112 strcpy(this->configFile, buffer); 113 free (buffer); 159 void OrxonoxGuiExec::setFileName(char* fileName) 160 { 161 if (!this->confDir) 162 this->setConfDir("~/"); 163 this->configFile = new char[strlen(this->confDir)+strlen(fileName)+2]; 164 sprintf(this->configFile, "%s/%s", this->confDir, fileName); 165 PRINTF(3)("ConfigurationFile is %s.\n", this->configFile); 114 166 } 115 167 … … 117 169 \returns The name of the Configuration-File 118 170 */ 119 char* OrxonoxGuiExec::getConfigFile(void) 171 char* OrxonoxGuiExec::getConfigFile(void) const 120 172 { 121 173 return this->configFile; -
orxonox/branches/updater/src/gui/orxonox_gui_exec.h
r3315 r3469 22 22 CheckButton* alwaysShow; //!< A CheckButton, for if orxonox should start with or without gui. 23 23 Button* quit; //!< A Button to quit the Gui without starting orxonox. 24 char* confDir; //!< The directory of the orxonox-configuration-files. 24 25 char* configFile; //!< The name of the .orxonox.conf(ig)-file. 25 26 FILE* CONFIG_FILE; //!< Filehandler for reading and writing. … … 37 38 38 39 Widget* getWidget(void); 39 40 void setFilename(char* filename); 41 char* getConfigFile(void); 40 41 void setConfFile(char* confFile); 42 void setConfDir(char* confDir); 43 void setFileName(char* fileName); 44 char* getConfigFile(void) const; 42 45 int shouldsave(void); 43 46 void writeToFile(Widget* widget);
Note: See TracChangeset
for help on using the changeset viewer.