aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/ios_utils.h23
-rw-r--r--tools/ios_utils.m19
2 files changed, 42 insertions, 0 deletions
diff --git a/tools/ios_utils.h b/tools/ios_utils.h
new file mode 100644
index 0000000000..0287dc14ae
--- /dev/null
+++ b/tools/ios_utils.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ios_util_DEFINED
+#define ios_util_DEFINED
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+ // cd into the current app's Documents/ directory.
+ // (This is the only directory we can easily read and write.)
+ void cd_Documents();
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif//ios_util_DEFINED
diff --git a/tools/ios_utils.m b/tools/ios_utils.m
new file mode 100644
index 0000000000..b88ab5bfe8
--- /dev/null
+++ b/tools/ios_utils.m
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#import <Foundation/Foundation.h>
+#include "ios_utils.h"
+#include <unistd.h>
+
+void cd_Documents() {
+ @autoreleasepool {
+ NSURL* dir = [[[NSFileManager defaultManager]
+ URLsForDirectory:NSDocumentDirectory
+ inDomains:NSUserDomainMask] lastObject];
+ chdir([dir.path UTF8String]);
+ }
+}