MainThread::MainThread(ANativeActivity *a):
asset_manager(a->assetManager),
+ int_data_path(a->internalDataPath),
starting_up(true)
{
attach_to_activity(a);
#include <android/native_activity.h>
#include <sigc++/signal.h>
+#include <msp/fs/path.h>
#include "mutex.h"
#include "thread.h"
private:
ANativeActivity *activity;
AAssetManager *asset_manager;
+ FS::Path int_data_path;
bool starting_up;
Mutex startup_mutex;
void resume_startup();
AAssetManager *get_asset_manager() const { return asset_manager; }
+ const FS::Path &get_internal_data_path() const { return int_data_path; }
private:
virtual void main();
--- /dev/null
+#include <msp/core/application.h>
+#include <msp/core/mainthread.h>
+#include "dir.h"
+
+using namespace std;
+
+namespace Msp {
+namespace FS {
+
+Path get_home_dir()
+{
+ return "/sdcard";
+}
+
+Path get_user_data_dir(const string &)
+{
+ Android::MainThread *thread = reinterpret_cast<Android::MainThread *>(Application::get_data());
+ return thread->get_internal_data_path();
+}
+
+} // namespace FS
+} // namespace Msp
-#include <cstdlib>
#include <unistd.h>
#include <sys/stat.h>
#include <msp/core/systemerror.h>
throw system_error("chdir");
}
-Path get_home_dir()
-{
- const char *home = getenv("HOME");
- if(home)
- return home;
- return ".";
-}
-
-Path get_user_data_dir(const string &appname)
-{
- if(appname.empty())
- throw invalid_argument("get_user_data_dir");
- return get_home_dir()/("."+appname);
-}
-
} // namespace FS
} // namespace Msp
--- /dev/null
+#include <cstdlib>
+#include "dir.h"
+
+using namespace std;
+
+namespace Msp {
+namespace FS {
+
+Path get_home_dir()
+{
+ const char *home = getenv("HOME");
+ if(home)
+ return home;
+ return ".";
+}
+
+Path get_user_data_dir(const string &appname)
+{
+ if(appname.empty())
+ throw invalid_argument("get_user_data_dir");
+ return get_home_dir()/("."+appname);
+}
+
+} // namespace FS
+} // namespace Msp
-#include <shlobj.h>
+#include <windows.h>
#include <msp/core/mutex.h>
#include <msp/core/systemerror.h>
#include "dir.h"
throw system_error("SetCurrentDirectory");
}
-Path get_home_dir()
-{
- char home[MAX_PATH];
- if(SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, home)==S_OK)
- return home;
- return ".";
-}
-
-Path get_user_data_dir(const string &appname)
-{
- if(appname.empty())
- throw invalid_argument("get_user_data_dir");
- char datadir[MAX_PATH];
- if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
- return Path(datadir)/appname;
- return ".";
-}
-
} // namespace FS
} // namespace Msp
--- /dev/null
+#include <shlobj.h>
+#include "dir.h"
+
+using namespace std;
+
+namespace Msp {
+namespace FS {
+
+Path get_home_dir()
+{
+ char home[MAX_PATH];
+ if(SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, home)==S_OK)
+ return home;
+ return ".";
+}
+
+Path get_user_data_dir(const string &appname)
+{
+ if(appname.empty())
+ throw invalid_argument("get_user_data_dir");
+ char datadir[MAX_PATH];
+ if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
+ return Path(datadir)/appname;
+ return ".";
+}
+
+} // namespace FS
+} // namespace Msp