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@berg-net.us> 8 * Julun <host.haiku@gmx.de> 9 * 10 */ 11 12 #include "TimeSettings.h" 13 #include "TimeMessages.h" 14 15 16 #include <File.h> 17 #include <FindDirectory.h> 18 #include <Path.h> 19 20 21 TimeSettings::TimeSettings() 22 : 23 fSettingsFile("Time_preflet_window") 24 { 25 } 26 27 28 TimeSettings::~TimeSettings() 29 { 30 } 31 32 33 BPoint 34 TimeSettings::LeftTop() const 35 { 36 BPath path; 37 BPoint leftTop(-1000.0, -1000.0); 38 39 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { 40 path.Append(fSettingsFile.String()); 41 42 BFile file(path.Path(), B_READ_ONLY); 43 if (file.InitCheck() == B_OK) { 44 BPoint tmp; 45 if (file.Read(&tmp, sizeof(BPoint)) == sizeof(BPoint)) 46 leftTop = tmp; 47 } 48 } 49 50 return leftTop; 51 } 52 53 54 void 55 TimeSettings::SetLeftTop(const BPoint leftTop) 56 { 57 BPath path; 58 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 59 return; 60 61 path.Append(fSettingsFile.String()); 62 63 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 64 if (file.InitCheck() == B_OK) 65 file.Write(&leftTop, sizeof(BPoint)); 66 } 67 68