Flutter Engine
paths_darwin.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/fml/paths.h"
6 
7 #include <Foundation/Foundation.h>
8 
9 #include "flutter/fml/file.h"
10 
11 namespace fml {
12 namespace paths {
13 
14 std::pair<bool, std::string> GetExecutableDirectoryPath() {
15  @autoreleasepool {
16  return {true, GetDirectoryName([NSBundle mainBundle].executablePath.UTF8String)};
17  }
18 }
19 
21  @autoreleasepool {
22  auto items = [[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory
23  inDomains:NSUserDomainMask];
24  if (items.count == 0) {
25  return {};
26  }
27 
28  return OpenDirectory(items[0].fileSystemRepresentation, false, FilePermission::kRead);
29  }
30 }
31 
32 } // namespace paths
33 } // namespace fml
fml::UniqueFD GetCachesDirectory()
Definition: ascii_trie.cc:9
std::string GetDirectoryName(const std::string &path)
Definition: paths_posix.cc:42
std::pair< bool, std::string > GetExecutableDirectoryPath()
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition: file_posix.cc:94