1 /* 2 * Copyright 2002-2007, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Andrew McCall, mccall@digitalparadise.co.uk 7 * Mike Berg <mike@agamemnon.homelinux.net> 8 * Julun <host.haiku@gmx.de> 9 */ 10 11 #include "TimeSettings.h" 12 #include "TimeMessages.h" 13 14 15 #include <File.h> 16 #include <FindDirectory.h> 17 #include <Path.h> 18 19 20 TimeSettings::TimeSettings() 21 : fSettingsFile("Time_settings") 22 { 23 } 24 25 26 TimeSettings::~TimeSettings() 27 { 28 } 29 30 31 BPoint 32 TimeSettings::LeftTop() const 33 { 34 BPath path; 35 BPoint leftTop(50.0, 50.0); 36 37 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { 38 path.Append(fSettingsFile.String()); 39 40 BFile file(path.Path(), B_READ_ONLY); 41 if (file.InitCheck() == B_OK) { 42 BPoint tmp; 43 if (file.Read(&tmp, sizeof(BPoint)) == sizeof(BPoint)) 44 leftTop = tmp; 45 } 46 } 47 48 return leftTop; 49 } 50 51 52 void 53 TimeSettings::SetLeftTop(const BPoint leftTop) 54 { 55 BPath path; 56 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 57 return; 58 59 path.Append(fSettingsFile.String()); 60 61 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 62 if (file.InitCheck() == B_OK) 63 file.Write(&leftTop, sizeof(BPoint)); 64 } 65 66