/* * Copyright 2002-2006, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors in chronological order: * Andrew McCall, mccall@digitalparadise.co.uk * Mike Berg */ #include "TimeSettings.h" #include "TimeMessages.h" #include #include #include #include #include #include const char TimeSettings::kTimeSettingsFile[] = "Time_settings"; TimeSettings::TimeSettings() { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK) { path.Append(kTimeSettingsFile); BFile file(path.Path(), B_READ_ONLY); if (file.InitCheck() == B_OK) { // Now read in the data if (file.Read(&fCorner, sizeof(BPoint)) != sizeof(BPoint)) { fCorner.x = 50; fCorner.y = 50; } } else { fCorner.x = 50; fCorner.y = 50; } } else be_app->PostMessage(ERROR_DETECTED); } TimeSettings::~TimeSettings() { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) return; path.Append(kTimeSettingsFile); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); if (file.InitCheck() == B_OK) { file.Write(&fCorner, sizeof(BPoint)); } } void TimeSettings::SetWindowCorner(BPoint corner) { fCorner = corner; }