OSDN Git Service

* {init_ / done_} core() に新たにapplicationの名前を表す引数を追加
authorcaprice <caprice@users.sourceforge.jp>
Tue, 13 May 2014 10:56:15 +0000 (19:56 +0900)
committercaprice <caprice@users.sourceforge.jp>
Tue, 13 May 2014 10:56:15 +0000 (19:56 +0900)
* post_officeのインスタンスを追加
* .tmpフォルダの作成処理を変更

src/GikoMona.cpp

index e33eedf..6fa0a3f 100644 (file)
@@ -1,5 +1,6 @@
 #include <exception>
 #include <memory>
+#include <sstream>
 
 #include <boost/filesystem.hpp>
 #include <boost/log/trivial.hpp>
@@ -10,6 +11,7 @@
 #include "GikoMona.hpp"
 #include "database.hpp"
 #include "model.hpp"
+#include "post-office.hpp"
 
 #include "extension.hpp"
 
@@ -19,28 +21,33 @@ namespace {
 
 std::shared_ptr<model> app_model;
 std::shared_ptr<extension> app_extension;
+std::shared_ptr<communication::post_office> app_postoffice;
 
 }
 
-bool init_core() {
+bool init_core(const mona_string& app_name) {
     wxXmlResource::Get()->InitAllHandlers();
     wxXmlResource::Get()->LoadAllFiles(wxT("resouce"));
     
     boost::system::error_code reason;
+    std::stringstream path_builder;
+    path_builder << ".tmp/" << app_name;
     
     // 一時解凍ファイルなどを溜め込む .tmp フォルダを作成
-    if(!boost::filesystem::create_directory(".tmp", reason)) {
+    if(!boost::filesystem::exists(path_builder.str(), reason) &&
+       !boost::filesystem::create_directories(path_builder.str(), reason)) {
         // log
         std::terminate();
     }
     
     app_model = std::make_shared<model>();
     app_extension = std::make_shared<extension>();
+    app_postoffice = std::make_shared<communication::post_office>(app_name);
     
     return true;
 }
 
-void done_core() noexcept {
+void done_core(const mona_string& app_name) noexcept {
     boost::system::error_code reason;
     boost::filesystem::remove_all(".tmp", reason);
     
@@ -52,7 +59,7 @@ void optimize_database(const boost::filesystem::path& db_path) {
     
     database db(db_path, ec);
     sqlite::connection con = db.get_connection();
-    
+
     mona_string sql(u8"SELECT counts-of-deleting-value FROM file-information;");
     auto count = sqlite::execute_statement<int>(db, sql, ec);