home *** CD-ROM | disk | FTP | other *** search
-
- #include "TheGuru.h"
-
- /* Record to hold all settings so we can load/save easier. */
- struct Settings {
- short time, sex, vol, rate, pitch, mode;
- };
-
- #define sSize sizeof (struct Settings)
-
- /* Variable to indicate if we have already read from current directory. */
- static int readfromcd;
-
- /*
- Read guru settings from the settings file.
- output - time, sex, vol, rate, pitch and mode hold the settings, but only if
- the loading succeeded. So init them with the default values before
- you call this procedure in case the file is not found.
- */
- void ReadGuruSettings (int *time, int *sex, int *vol, int *rate,
- int *pitch, int *mode)
- {
- struct Settings s;
- BPTR file;
-
- /* Try to open the settings config file (in the current directory first). */
- readfromcd = TRUE;
- file = Open (GURU_SETTINGSFILE_CD, MODE_OLDFILE);
- if (!file) {
- readfromcd = FALSE;
- file = Open (GURU_SETTINGSFILE, MODE_OLDFILE);
- if (!file) return;
- }
- /* Read the settings. */
- if (Read (file, &s, sSize) == sSize) {
- /* If success assign settings to variables. */
- *time = s.time; *sex = s.sex; *vol = s.vol; *rate = s.rate;
- *pitch = s.pitch; *mode = s.mode;
- }
- Close (file);
- }
-