6
6
7
7
#include < EGL/egl.h>
8
8
#include < sys/types.h>
9
- #include < unistd.h>
10
9
11
10
#include < chrono>
12
11
#include < sstream>
13
12
#include < vector>
14
13
14
+ #include " utils.h"
15
+
15
16
namespace flutter {
16
17
17
18
static_assert (FLUTTER_ENGINE_VERSION == 1 , " " );
18
19
19
20
static const char * kICUDataFileName = " icudtl.dat" ;
20
21
21
- static std::string GetExecutableDirectory () {
22
- char executable_path[1024 ] = {0 };
23
- std::stringstream stream;
24
- stream << " /proc/" << getpid () << " /exe" ;
25
- auto path = stream.str ();
26
- auto executable_path_size =
27
- ::readlink (path.c_str(), executable_path, sizeof(executable_path));
28
- if (executable_path_size <= 0 ) {
29
- return " " ;
30
- }
31
-
32
- auto path_string =
33
- std::string{executable_path, static_cast <size_t >(executable_path_size)};
34
-
35
- auto found = path_string.find_last_of (' /' );
36
-
37
- if (found == std::string::npos) {
38
- return " " ;
39
- }
40
-
41
- return path_string.substr (0 , found + 1 );
42
- }
43
-
44
22
static std::string GetICUDataPath () {
45
23
auto exe_dir = GetExecutableDirectory ();
46
24
if (exe_dir == " " ) {
@@ -51,7 +29,7 @@ static std::string GetICUDataPath() {
51
29
52
30
auto icu_path = stream.str ();
53
31
54
- if (:: access (icu_path.c_str (), R_OK) != 0 ) {
32
+ if (! FileExistsAtPath (icu_path.c_str ()) ) {
55
33
FLWAY_ERROR << " Could not find " << icu_path << std::endl;
56
34
return " " ;
57
35
}
@@ -60,9 +38,15 @@ static std::string GetICUDataPath() {
60
38
}
61
39
62
40
FlutterApplication::FlutterApplication (
41
+ std::string bundle_path,
63
42
const std::vector<std::string>& command_line_args,
64
43
RenderDelegate& render_delegate)
65
44
: render_delegate_(render_delegate) {
45
+ if (!FlutterAssetBundleIsValid (bundle_path)) {
46
+ FLWAY_ERROR << " Flutter asset bundle was not valid." << std::endl;
47
+ return ;
48
+ }
49
+
66
50
FlutterRendererConfig config = {};
67
51
config.type = kOpenGL ;
68
52
config.open_gl .struct_size = sizeof (config.open_gl );
@@ -92,11 +76,6 @@ FlutterApplication::FlutterApplication(
92
76
return nullptr ;
93
77
};
94
78
95
- // TODO: Pipe this in through command line args.
96
- #define MY_PROJECT \
97
- " /usr/local/google/home/chinmaygarde/VersionControlled/flutter/examples/" \
98
- " flutter_gallery/build/flutter_assets"
99
-
100
79
auto icu_data_path = GetICUDataPath ();
101
80
102
81
if (icu_data_path == " " ) {
@@ -114,7 +93,7 @@ FlutterApplication::FlutterApplication(
114
93
115
94
FlutterProjectArgs args = {
116
95
.struct_size = sizeof (FlutterProjectArgs),
117
- .assets_path = MY_PROJECT ,
96
+ .assets_path = bundle_path. c_str () ,
118
97
.main_path = " " ,
119
98
.packages_path = " " ,
120
99
.icu_data_path = icu_data_path.c_str (),
0 commit comments