[gnote] Add file_modification_time to fileinfo



commit 4de478fc6f341991ed9f739a03b33e31babc082d
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date:   Fri Apr 29 23:40:36 2011 +0300

    Add file_modification_time to fileinfo
    
    A function to get file modification time.

 src/sharp/fileinfo.cpp |   11 +++++++++++
 src/sharp/fileinfo.hpp |    6 ++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/sharp/fileinfo.cpp b/src/sharp/fileinfo.cpp
index a53d570..846dd34 100644
--- a/src/sharp/fileinfo.cpp
+++ b/src/sharp/fileinfo.cpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2011 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,6 +25,8 @@
 
 
 #include <glibmm.h>
+#include <giomm/file.h>
+#include <giomm/fileinfo.h>
 #include "sharp/fileinfo.hpp"
 
 
@@ -57,4 +60,12 @@ namespace sharp {
   }
 
 
+  DateTime file_modification_time(const std::string &path)
+  {
+    Glib::RefPtr<Gio::FileInfo> file_info = Gio::File::create_for_path(path)->query_info(
+        G_FILE_ATTRIBUTE_TIME_MODIFIED + std::string(",") + G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
+    if(file_info)
+      return DateTime(file_info->modification_time());
+    return DateTime();
+  }
 }
diff --git a/src/sharp/fileinfo.hpp b/src/sharp/fileinfo.hpp
index d14619e..fecf90d 100644
--- a/src/sharp/fileinfo.hpp
+++ b/src/sharp/fileinfo.hpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2011 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,6 +30,8 @@
 
 #include <string>
 
+#include "sharp/datetime.hpp"
+
 namespace sharp {
 
 
@@ -45,6 +48,9 @@ private:
   std::string m_path;
 };
 
+
+DateTime file_modification_time(const std::string &);
+
 }
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]