[gnote] Use file reading/writing utilities in FileSystemSyncServiceAddin



commit b5a91b2c80fe5d7099b1c58f7f32e0e5e0dfd881
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Thu Feb 16 13:08:23 2017 +0200

    Use file reading/writing utilities in FileSystemSyncServiceAddin

 .../filesystemsyncserviceaddin.cpp                 |   20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)
---
diff --git a/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp 
b/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
index 54f77ef..c869586 100644
--- a/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
+++ b/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
@@ -18,7 +18,6 @@
  */
 
 
-#include <fstream>
 #include <stdexcept>
 
 #include <glibmm/i18n.h>
@@ -156,11 +155,7 @@ bool FileSystemSyncServiceAddin::save_configuration()
 
     // Test ability to create and write
     Glib::ustring testLine = "Testing write capabilities.";
-    std::ofstream fout(testPath.c_str());
-    if(fout.is_open()) {
-      fout << testLine;
-      fout.close();
-    }
+    sharp::file_write_all_text(testPath, testLine);
 
     // Test ability to read
     bool testFileFound = false;
@@ -173,16 +168,11 @@ bool FileSystemSyncServiceAddin::save_configuration()
       }
     }
     if(!testFileFound) {
-      ; // TODO: Throw gnote::sync::GnoteSyncException
+      throw sharp::Exception("Failure writing test file");
     }
-    std::ifstream fin(testPath.c_str());
-    if(fin.is_open()) {
-      std::string line;
-      std::getline(fin, line);
-      fin.close();
-      if(line != testLine) {
-        ; // TODO: Throw gnote::sync::GnoteSyncException
-      }
+    Glib::ustring line = sharp::file_read_all_text(testPath);
+    if(line != testLine) {
+      throw sharp::Exception("Failure when checking test file contents");
     }
 
     // Test ability to delete


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