defuze.me  Client
location.cpp
00001 /**************************************************************************
00002 ** defuze.me Epitech Innovative Project
00003 **
00004 ** Copyright 2010
00005 **   Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard
00006 **   Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier
00007 **
00008 ** All rights reserved.
00009 **************************************************************************/
00010 
00011 #include "location.hpp"
00012 
00013 using namespace DB;
00014 
00015 Location::Location(const QString path) : infos(path)
00016 {
00017     _open = false;
00018 }
00019 
00020 QString     Location::filePath() const
00021 {
00022     return infos.absoluteFilePath();
00023 }
00024 
00025 QDir        Location::dirPath() const
00026 {
00027     return infos.absoluteDir();
00028 }
00029 
00030 bool        Location::exists() const
00031 {
00032     return infos.exists();
00033 }
00034 
00035 QDateTime   Location::lastModified() const
00036 {
00037     return infos.lastModified();
00038 }
00039 
00040 int         Location::age() const
00041 {
00042     if (_open)
00043         return 0;
00044     else
00045         return lastModified().secsTo(QDateTime::currentDateTime());
00046 }
00047 
00048 bool&       Location::open()
00049 {
00050     return _open;
00051 }
00052 
00053 void        Location::reload()
00054 {
00055     infos.refresh();
00056 }
00057 
00058 void        Location::mkPath() const
00059 {
00060     QDir dir(dirPath());
00061     dir.mkpath("./");
00062 }