aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-02-06 09:26:14 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-06 15:06:45 +0000
commitadacaef799455013bf00b85a43237ac8d9471ade (patch)
tree7627e4e464a23078952830ed14c449330ba2d515 /tools
parentc34b235871dacd0f3b840508dbbc5555ec9ede0d (diff)
iOS: cd into Documents folder at startup
CQ_INCLUDE_TRYBOTS=skia.primary:Test-iOS-Clang-iPadMini4-GPU-GX6450-arm-Release Change-Id: I7beadad742bc9444491c7a315a827297a636d70d Reviewed-on: https://skia-review.googlesource.com/8049 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
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]);
+ }
+}