32 #include "lib/charbuf.h" 37 #include <clib/dos_protos.h> 39 static const char *tempname =
"ENV:amath.prefs";
40 static const char *permname =
"ENVARC:amath.prefs";
42 bool AmigaPreferences::Load()
44 BPTR file = Open((
char*)tempname, MODE_OLDFILE);
49 CharBuffer *text =
new CharBuffer();
52 const int bufsize = 64;
53 char* buf =
new char[bufsize];
58 c = FGets(file, buf, bufsize);
60 text->EnsureSize(s++);
63 }
while (c !=
nullptr);
67 SetPrefs(text->GetString());
69 return (IoErr() == 0);
72 bool AmigaPreferences::Keep()
74 return SavePrefs(tempname);
77 bool AmigaPreferences::Save()
79 return SavePrefs(permname);
82 bool AmigaPreferences::SavePrefs(
const char* name)
84 BPTR file = Open((CONST_STRPTR)name, MODE_NEWFILE);
90 char *out = GetDescription();
91 FPuts(file, (CONST_STRPTR)out);
93 return (IoErr() == 0);