commit 4b967ea39555fd87619e0c24ce6636e48cc0f5a9
Author: jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Sun Apr 17 16:24:07 2022 -0600
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Sun Apr 17 16:24:07 2022 -0600
Ensure cdata dir is created on OD and Bittboy
TODO: reduce code duplication
---
platform/bittboy/source/BittBoyHost.cpp | 10 ++++++++++
platform/gcw0/source/ODHost.cpp | 11 +++++++++++
2 files changed, 21 insertions(+)
diff --git a/platform/bittboy/source/BittBoyHost.cpp b/platform/bittboy/source/BittBoyHost.cpp
index 47bea39..f253048 100644
--- a/platform/bittboy/source/BittBoyHost.cpp
+++ b/platform/bittboy/source/BittBoyHost.cpp
@@ -3,6 +3,8 @@
#include <string.h>
#include <dirent.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <fstream>
#include <iostream>
@@ -181,6 +183,14 @@ Host::Host() {
_logFilePrefix = home + "/fake08";
#endif
+
+ struct stat st = {0};
+ int res = 0;
+
+ string cartdatadir = _logFilePrefix + "cdata";
+ if (stat(cartdatadir.c_str(), &st) == -1) {
+ res = mkdir(cartdatadir.c_str(), 0777);
+ }
}
void Host::oneTimeSetup(Audio* audio){
diff --git a/platform/gcw0/source/ODHost.cpp b/platform/gcw0/source/ODHost.cpp
index 468f5be..a9b8e89 100644
--- a/platform/gcw0/source/ODHost.cpp
+++ b/platform/gcw0/source/ODHost.cpp
@@ -3,6 +3,9 @@
#include <string.h>
#include <dirent.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
#include <fstream>
#include <iostream>
@@ -196,6 +199,14 @@ Host::Host() {
_cartDirectory = home + "/p8carts";
_logFilePrefix = home + "/fake08";
#endif
+
+ struct stat st = {0};
+ int res = 0;
+
+ string cartdatadir = _logFilePrefix + "cdata";
+ if (stat(cartdatadir.c_str(), &st) == -1) {
+ res = mkdir(cartdatadir.c_str(), 0777);
+ }
}
void Host::oneTimeSetup(Audio* audio){