Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5c19602

Browse files
authored
Fix filesystem access prior to macOS 10.15 (#21740)
1 parent 15ac210 commit 5c19602

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

shell/platform/darwin/macos/framework/Source/FlutterEngine.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
88

99
#include <algorithm>
10-
#include <filesystem>
1110
#include <vector>
1211

1312
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
@@ -324,24 +323,25 @@ - (UniqueAotDataPtr)loadAOTData:(NSString*)assetsDir {
324323
return nullptr;
325324
}
326325

326+
BOOL isDirOut = false; // required for NSFileManager fileExistsAtPath.
327+
NSFileManager* fileManager = [NSFileManager defaultManager];
328+
327329
// This is the location where the test fixture places the snapshot file.
328330
// For applications built by Flutter tool, this is in "App.framework".
329-
std::filesystem::path assetsFsDir(assetsDir.UTF8String);
330-
std::filesystem::path elfFile("app_elf_snapshot.so");
331-
auto fullElfPath = assetsFsDir / elfFile;
331+
NSString* elfPath = [NSString pathWithComponents:@[ assetsDir, @"app_elf_snapshot.so" ]];
332332

333-
if (!std::filesystem::exists(fullElfPath)) {
333+
if (![fileManager fileExistsAtPath:elfPath isDirectory:&isDirOut]) {
334334
return nullptr;
335335
}
336336

337337
FlutterEngineAOTDataSource source = {};
338338
source.type = kFlutterEngineAOTDataSourceTypeElfPath;
339-
source.elf_path = fullElfPath.c_str();
339+
source.elf_path = [elfPath cStringUsingEncoding:NSUTF8StringEncoding];
340340

341341
FlutterEngineAOTData data = nullptr;
342342
auto result = FlutterEngineCreateAOTData(&source, &data);
343343
if (result != kSuccess) {
344-
NSLog(@"Failed to load AOT data from: %@", @(fullElfPath.c_str()));
344+
NSLog(@"Failed to load AOT data from: %@", elfPath);
345345
return nullptr;
346346
}
347347

0 commit comments

Comments
 (0)