Flutter Engine
The Flutter Engine
SkSLModuleDataFile.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
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
10#include "src/utils/SkOSPath.h"
12
13#include <fstream>
14
15namespace SkSL {
16
17std::string GetModuleData(ModuleName /*name*/, const char* filename) {
18 std::string exePath = SkGetExecutablePath();
19 SkString exeDir = SkOSPath::Dirname(exePath.c_str());
20 SkString modulePath = SkOSPath::Join(exeDir.c_str(), filename);
21 std::ifstream in(std::string{modulePath.c_str()});
22 std::string moduleSource{std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()};
23 if (in.rdstate()) {
24 SK_ABORT("Error reading %s\n", modulePath.c_str());
25 }
26 return moduleSource;
27}
28
29} // namespace SkSL
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
std::string SkGetExecutablePath()
static SkString Join(const char *rootPath, const char *relativePath)
Definition: SkOSPath.cpp:14
static SkString Dirname(const char *fullPath)
Definition: SkOSPath.cpp:36
const char * c_str() const
Definition: SkString.h:133
std::string GetModuleData(ModuleName name, const char *filename)