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 8 #include "src/sksl/SkSLModule.h" 9 10 #include "include/core/SkString.h" 11 #include "src/utils/SkGetExecutablePath.h" 12 #include "src/utils/SkOSPath.h" 13 14 #include <fstream> 15 16 namespace SkSL { 17 GetModuleData(ModuleType,const char * filename)18std::string GetModuleData(ModuleType /*name*/, const char* filename) { 19 std::string exePath = SkGetExecutablePath(); 20 SkString exeDir = SkOSPath::Dirname(exePath.c_str()); 21 SkString modulePath = SkOSPath::Join(exeDir.c_str(), filename); 22 std::ifstream in(std::string{modulePath.c_str()}); 23 std::string moduleSource{std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()}; 24 if (in.rdstate()) { 25 SK_ABORT("Error reading %s\n", modulePath.c_str()); 26 } 27 return moduleSource; 28 } 29 30 } // namespace SkSL 31