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 : fSettingsFile("Time_preflet_window") 23 { 24 } 25 26 27 TimeSettings::~TimeSettings() 28 { 29 } 30 31 32 BPoint 33 TimeSettings::LeftTop() const 34 { 35 BPath path; 36 BPoint leftTop(-1000.0, -1000.0); 37 38 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { 39 path.Append(fSettingsFile.String()); 40 41 BFile file(path.Path(), B_READ_ONLY); 42 if (file.InitCheck() == B_OK) { 43 BPoint tmp; 44 if (file.Read(&tmp, sizeof(BPoint)) == sizeof(BPoint)) 45 leftTop = tmp; 46 } 47 } 48 49 return leftTop; 50 } 51 52 53 void 54 TimeSettings::SetLeftTop(const BPoint leftTop) 55 { 56 BPath path; 57 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 58 return; 59 60 path.Append(fSettingsFile.String()); 61 62 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 63 if (file.InitCheck() == B_OK) 64 file.Write(&leftTop, sizeof(BPoint)); 65 } 66 67