Lagrange
Loading...
Searching...
No Matches
file_utils.h
1/*
2 * Copyright 2020 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/fs/api.h>
15#include <lagrange/fs/filesystem.h>
16
17#include <string>
18#include <unordered_map>
19
20namespace lagrange {
21namespace fs {
22
25LA_FS_API std::string get_filename_extension(const std::string& filename);
26
27LA_FS_API std::string get_base_dir(const std::string& filename);
28
30LA_FS_API std::string get_string_ending_with(const std::string& str, const char* suffix);
31
32LA_FS_API std::string read_file_to_string(const path& path);
33LA_FS_API std::string read_file_with_includes(const path& search_dir, const path& filepath);
34LA_FS_API std::string read_file_with_includes(
35 const path& filepath,
36 const std::unordered_map<std::string, std::string>& virtual_fs);
37
38// The executable is not present in WebAssembly's virtual file system, so it does not make sense
39// to provide get_executable_path() or get_executable_directory() when building with Emscripten.
40#if !defined(__EMSCRIPTEN__)
41LA_FS_API path get_executable_path();
42
43LA_FS_API path get_executable_directory();
44#endif
45
47LA_FS_API path get_current_working_directory();
48
49} // namespace fs
50} // namespace lagrange
Main namespace for Lagrange.