Flutter Engine
file_loader_posix.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include <iostream>
8 #include <memory>
9 #include <utility>
10 
11 #include "tonic/common/macros.h"
16 
17 namespace tonic {
18 
19 const std::string FileLoader::kPathSeparator = "/";
20 const char FileLoader::kFileURLPrefix[] = "file://";
22  sizeof(FileLoader::kFileURLPrefix) - 1;
23 
24 namespace {
25 
26 const size_t kFileSchemeLength = FileLoader::kFileURLPrefixLength - 2;
27 
28 } // namespace
29 
30 std::string FileLoader::SanitizePath(const std::string& url) {
31  return SanitizeURIEscapedCharacters(url);
32 }
33 
34 std::string FileLoader::CanonicalizeFileURL(const std::string& url) {
35  return url.substr(kFileSchemeLength);
36 }
37 
38 bool FileLoader::ReadFileToString(const std::string& path,
39  std::string* result) {
40  TONIC_DCHECK(dirfd_ == -1);
41  return filesystem::ReadFileToString(path, result);
42 }
43 
44 std::pair<uint8_t*, intptr_t> FileLoader::ReadFileToBytes(
45  const std::string& path) {
46  TONIC_DCHECK(dirfd_ == -1);
47  return filesystem::ReadFileToBytes(path);
48 }
49 
50 } // namespace tonic
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
#define TONIC_DCHECK
Definition: macros.h:32
std::pair< uint8_t *, intptr_t > ReadFileToBytes(const std::string &path)
Definition: file.cc:94
static const char kFileURLPrefix[]
Definition: file_loader.h:42
static const std::string kPathSeparator
Definition: file_loader.h:44
static const size_t kFileURLPrefixLength
Definition: file_loader.h:43
bool ReadFileToString(const std::string &path, std::string *result)
Definition: file.cc:85