[dasher: 145/217] Add a CFileUtils implementation in Linux so it builds.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 145/217] Add a CFileUtils implementation in Linux so it builds.
- Date: Sat, 27 Feb 2016 12:12:31 +0000 (UTC)
commit 6f59d3184d64871916968fb40236cba77fc45168
Author: lbaudoin <lbaudoin google com>
Date: Sun Dec 13 16:55:36 2015 -0700
Add a CFileUtils implementation in Linux so it builds.
Src/DasherCore/XmlSettingsStore.cpp | 2 +-
Src/Gtk2/DasherControl.cpp | 29 +--------------------------
Src/Gtk2/DasherControl.h | 5 +--
Src/Gtk2/FileUtils.cpp | 37 +++++++++++++++++++++++++++++++++++
Src/Gtk2/FileUtils.h | 14 +++++++++++++
Src/Gtk2/Makefile.am | 2 +
6 files changed, 57 insertions(+), 32 deletions(-)
---
diff --git a/Src/DasherCore/XmlSettingsStore.cpp b/Src/DasherCore/XmlSettingsStore.cpp
index f305081..e4953ab 100644
--- a/Src/DasherCore/XmlSettingsStore.cpp
+++ b/Src/DasherCore/XmlSettingsStore.cpp
@@ -12,7 +12,7 @@
#define strcasecmp _stricmp
#define widen(a) WinUTF8::UTF8string_to_wstring((a))
#else
-#define widen((a)) (a)
+#define widen(a) (a)
#endif
namespace Dasher {
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index d49daa3..ac83a8e 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -41,7 +41,7 @@ static bool g_iTimeoutID = 0;
// CDasherControl class definitions
CDasherControl::CDasherControl(GtkVBox *pVBox, GtkDasherControl *pDasherControl,
CSettingsStore* settings)
- : CDashIntfScreenMsgs(settings) {
+ : CDashIntfScreenMsgs(settings, &file_utils_) {
m_pScreen = NULL;
m_pDasherControl = pDasherControl;
@@ -123,24 +123,6 @@ void CDasherControl::CreateModules() {
#endif
}
-void CDasherControl::ScanFiles(AbstractParser *parser, const std::string &strPattern) {
-
- //System files.
- // PROGDATA is provided by the makefile
- string path(PROGDATA "/");
- path += strPattern;
-
- //User files.
- mkdir(m_user_data_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- string user_path(m_user_data_dir);
- user_path += strPattern;
-
- const char *user[2], *sys[2];
- user[0] = user_path.c_str(); sys[0] = path.c_str();
- user[1] = sys[1] = NULL; //terminators
-
- globScan(parser, user, sys);
-}
void CDasherControl::ClearAllContext() {
gtk_dasher_control_clear_all_context(m_pDasherControl);
@@ -647,15 +629,6 @@ void CDasherControl::UserLogNewTrial()
}
}
-int CDasherControl::GetFileSize(const std::string &strFileName) {
- struct stat sStatInfo;
-
- if(!stat(strFileName.c_str(), &sStatInfo))
- return sStatInfo.st_size;
- else
- return 0;
-}
-
// "C" style callbacks - these are here just because it's not possible
// (or at least not easy) to connect a callback directly to a C++
// method, so we pass a pointer to th object in the user_data field
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 8279f7c..c1c9dfd 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -29,6 +29,7 @@
#include "../DasherCore/DashIntfScreenMsgs.h"
#include "GnomeSettingsStore.h"
#include "../DasherCore/UserLog.h"
+#include "FileUtils.h"
///
/// \brief C++ core of the Dasher GTK UI component.
@@ -134,7 +135,6 @@ public:
///Override to broadcast dasher_stop signal...
void Done() override;
void WriteTrainFile(const std::string &filename, const std::string &strNewText) override;
- int GetFileSize(const std::string &strFileName) override;
void ClearAllContext() override ;
std::string GetAllContext() override;
@@ -169,7 +169,6 @@ public:
CGameModule *CreateGameModule() override;
private:
- virtual void ScanFiles(AbstractParser *parser, const std::string &strPattern) override;
virtual void CreateModules() override;
GtkWidget *m_pVBox;
@@ -205,7 +204,7 @@ private:
//Cache the clipboard object...
GtkClipboard *pClipboard;
-
+ FileUtils file_utils_;
#ifdef WITH_SPEECH
CSpeech m_Speech;
#endif
diff --git a/Src/Gtk2/FileUtils.cpp b/Src/Gtk2/FileUtils.cpp
new file mode 100644
index 0000000..3f0a280
--- /dev/null
+++ b/Src/Gtk2/FileUtils.cpp
@@ -0,0 +1,37 @@
+#include <string>
+
+#include "../Common/Globber.h"
+#include "../DasherCore/AbstractXMLParser.h"
+#include "../DasherCore/DasherInterfaceBase.h"
+#include "FileUtils.h"
+
+int FileUtils::GetFileSize(const std::string &strFileName) {
+ struct stat sStatInfo;
+
+ if(!stat(strFileName.c_str(), &sStatInfo))
+ return sStatInfo.st_size;
+ else
+ return 0;
+}
+
+void FileUtils::ScanFiles(AbstractParser *parser, const std::string &strPattern) {
+ //System files.
+ // PROGDATA is provided by the makefile
+ string path(PROGDATA "/");
+ path += strPattern;
+
+ std::string user_data_dir= getenv("HOME");
+ user_data_dir += "/.dasher/";
+
+ //User files.
+ mkdir(user_data_dir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ string user_path = user_data_dir;
+ user_path += strPattern;
+
+ const char *user[2], *sys[2];
+ user[0] = user_path.c_str();
+ sys[0] = path.c_str();
+ user[1] = sys[1] = nullptr; //terminators
+
+ globScan(parser, user, sys);
+}
diff --git a/Src/Gtk2/FileUtils.h b/Src/Gtk2/FileUtils.h
new file mode 100644
index 0000000..bebfb12
--- /dev/null
+++ b/Src/Gtk2/FileUtils.h
@@ -0,0 +1,14 @@
+#ifndef DASHER_FILEUTILS_H
+#define DASHER_FILEUTILS_H
+
+#include <string>
+#include "../DasherCore/DasherInterfaceBase.h"
+
+class FileUtils : public CFileUtils {
+public:
+ ~FileUtils() override = default;
+ int GetFileSize(const std::string &strFileName) override;
+ void ScanFiles(AbstractParser *parser, const std::string &strPattern) override;
+};
+
+#endif //DASHER_FILEUTILS_H
diff --git a/Src/Gtk2/Makefile.am b/Src/Gtk2/Makefile.am
index e456f49..bd71e03 100644
--- a/Src/Gtk2/Makefile.am
+++ b/Src/Gtk2/Makefile.am
@@ -76,6 +76,8 @@ libdashergtk_la_SOURCES = \
dasher_lock_dialogue.h \
dasher_main.cpp \
dasher_main.h \
+ FileUtils.h \
+ FileUtils.cpp \
module_settings_window.cpp \
module_settings_window.h
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]