4 #include <boost/filesystem.hpp>
5 #include <boost/log/trivial.hpp>
7 #include <wx/xrc/xmlres.h>
10 #include "GikoMona.hpp"
11 #include "database.hpp"
14 #include "extension.hpp"
16 namespace monazilla { namespace GikoMona { namespace core {
20 std::shared_ptr<model> app_model;
21 std::shared_ptr<extension> app_extension;
26 wxXmlResource::Get()->InitAllHandlers();
27 wxXmlResource::Get()->LoadAllFiles(wxT("resouce"));
29 boost::system::error_code reason;
31 // 一時解凍ファイルなどを溜め込む .tmp フォルダを作成
32 if(!boost::filesystem::create_directory(".tmp", reason)) {
37 app_model = std::make_shared<model>();
38 app_extension = std::make_shared<extension>();
43 void done_core() noexcept {
44 boost::system::error_code reason;
45 boost::filesystem::remove_all(".tmp", reason);
47 optimize_database("./history.db");
50 void optimize_database(const boost::filesystem::path& db_path) {
51 boost::system::error_code ec;
53 database db(db_path, ec);
54 sqlite::connection con = db.get_connection();
56 mona_string sql(u8"SELECT counts-of-deleting-value FROM file-information;");
57 auto count = sqlite::execute_statement<int>(db, sql, ec);
59 if(!count) { /* log */ }
61 if(count->at<0>(0) >= 1000) {