Lines 76-82
Link Here
|
76 |
// config file. It first checks the user's home directory, |
76 |
// config file. It first checks the user's home directory, |
77 |
// and if that fails it uses the CONFIG_DIR defined in the |
77 |
// and if that fails it uses the CONFIG_DIR defined in the |
78 |
// makefile. |
78 |
// makefile. |
79 |
char *get_config_location(bool write) { |
79 |
string get_config_location(bool write) { |
80 |
#ifdef LINUX |
80 |
#ifdef LINUX |
81 |
// Get the path to the config file |
81 |
// Get the path to the config file |
82 |
string tmp = get_tomatoes_dir() + "config.cfg"; |
82 |
string tmp = get_tomatoes_dir() + "config.cfg"; |
Lines 91-97
Link Here
|
91 |
fclose(ftest); |
91 |
fclose(ftest); |
92 |
} |
92 |
} |
93 |
|
93 |
|
94 |
return (char*)tmp.c_str(); |
94 |
return tmp; |
95 |
#endif |
95 |
#endif |
96 |
|
96 |
|
97 |
// Return the CONFIG_DIR |
97 |
// Return the CONFIG_DIR |
Lines 100-110
Link Here
|
100 |
|
100 |
|
101 |
|
101 |
|
102 |
// Load config from file |
102 |
// Load config from file |
103 |
void load_config(char *file, CONFIG *conf) { |
103 |
void load_config(string file, CONFIG *conf) { |
104 |
|
104 |
|
105 |
FILE *f = fopen(file, "rt"); |
105 |
FILE *f = fopen(file.c_str(), "rt"); |
106 |
if(!f) |
106 |
if(!f) |
107 |
error_msg("Unable to load config file: %s!", file); |
107 |
error_msg("Unable to load config file: %s!", file.c_str()); |
108 |
|
108 |
|
109 |
fscanf(f, "video_mode = %d x %d\n", &(conf->vid_w), &(conf->vid_h)); |
109 |
fscanf(f, "video_mode = %d x %d\n", &(conf->vid_w), &(conf->vid_h)); |
110 |
fscanf(f, "video_mode_color_depth = %d\n", &(conf->vid_color_depth)); |
110 |
fscanf(f, "video_mode_color_depth = %d\n", &(conf->vid_color_depth)); |
Lines 127-137
Link Here
|
127 |
|
127 |
|
128 |
|
128 |
|
129 |
// Save config to file |
129 |
// Save config to file |
130 |
void save_config(char *file, CONFIG *conf) { |
130 |
void save_config(string file, CONFIG *conf) { |
131 |
|
131 |
|
132 |
FILE *f = fopen(file, "wt"); |
132 |
FILE *f = fopen(file.c_str(), "wt"); |
133 |
if(!f) |
133 |
if(!f) |
134 |
error_msg("Unable to save config file: %s!", file); |
134 |
error_msg("Unable to save config file: %s!", file.c_str()); |
135 |
|
135 |
|
136 |
fprintf(f, "video_mode = %d x %d\n", (conf->vid_w), (conf->vid_h)); |
136 |
fprintf(f, "video_mode = %d x %d\n", (conf->vid_w), (conf->vid_h)); |
137 |
fprintf(f, "video_mode_color_depth = %d\n", (conf->vid_color_depth)); |
137 |
fprintf(f, "video_mode_color_depth = %d\n", (conf->vid_color_depth)); |