blob: 43c7ae15aa02717a8dac5b855c0bfbaa682af63e [file] [log] [blame]
John Stiles964d8f12022-10-26 13:52:03 -04001/*
2 * Copyright 2022 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "tools/SkGetExecutablePath.h"
9#include <mach-o/dyld.h>
10
John Stilesf04b8272022-11-04 13:58:26 -040011std::string SkGetExecutablePath() {
John Stiles964d8f12022-10-26 13:52:03 -040012 uint32_t size = 0;
13 _NSGetExecutablePath(nullptr, &size);
14
John Stilesf04b8272022-11-04 13:58:26 -040015 std::string result(size, '\0');
John Stiles1e64fb92022-10-27 14:02:39 -040016 if (_NSGetExecutablePath(result.data(), &size) != 0) {
John Stilesf04b8272022-11-04 13:58:26 -040017 result.clear();
John Stiles964d8f12022-10-26 13:52:03 -040018 }
19 return result;
20}