src/utils/SkGetExecutablePath_mac.cpp
raw| 1 | /* |
| 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 "src/utils/SkGetExecutablePath.h" |
| 9 | |
| 10 | #include <mach-o/dyld.h> |
| 11 | |
| 12 | std::string SkGetExecutablePath() { |
| 13 | uint32_t size = 0; |
| 14 | _NSGetExecutablePath(nullptr, &size); |
| 15 | |
| 16 | std::string result(size, '\0'); |
| 17 | if (_NSGetExecutablePath(result.data(), &size) != 0) { |
| 18 | result.clear(); |
| 19 | } |
| 20 | return result; |
| 21 | } |