1 /* 2 * TimeSettings.cpp 3 * Time mccall@@digitalparadise.co.uk 4 * 5 */ 6 7 #include <Application.h> 8 #include <FindDirectory.h> 9 #include <File.h> 10 #include <Path.h> 11 #include <String.h> 12 #include <stdio.h> 13 14 #include "TimeSettings.h" 15 #include "TimeMessages.h" 16 17 const char TimeSettings::kTimeSettingsFile[] = "Time_settings"; 18 19 20 TimeSettings::TimeSettings() 21 { 22 BPath path; 23 24 if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK) { 25 path.Append(kTimeSettingsFile); 26 BFile file(path.Path(), B_READ_ONLY); 27 if (file.InitCheck() == B_OK) { 28 // Now read in the data 29 if (file.Read(&fCorner, sizeof(BPoint)) != sizeof(BPoint)) { 30 fCorner.x=50; 31 fCorner.y=50; 32 }; 33 } else { 34 fCorner.x=50; 35 fCorner.y=50; 36 } 37 } else 38 be_app->PostMessage(ERROR_DETECTED); 39 } 40 41 42 TimeSettings::~TimeSettings() 43 { 44 BPath path; 45 46 if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) < B_OK) 47 return; 48 49 path.Append(kTimeSettingsFile); 50 51 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 52 if (file.InitCheck() == B_OK) { 53 file.Write(&fCorner, sizeof(BPoint)); 54 } 55 56 57 } 58 59 60 void 61 TimeSettings::SetWindowCorner(BPoint corner) 62 { 63 fCorner=corner; 64 } 65