From: Jacob Lifshay Date: Thu, 29 Jun 2017 07:24:50 +0000 (-0700) Subject: change json::Source::load_file to accept a filesystem::path X-Git-Tag: gsoc-2017~78 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47e3c58cd9bdfd660f0fc377e2434696234ecde0;p=kazan.git change json::Source::load_file to accept a filesystem::path --- diff --git a/src/json/source.cpp b/src/json/source.cpp index 40b5662..833bee1 100644 --- a/src/json/source.cpp +++ b/src/json/source.cpp @@ -98,12 +98,12 @@ std::vector Source::find_line_start_indexes(const char *contents, return retval; } -Source Source::load_file(std::string file_name) +Source Source::load_file(const util::filesystem::path &file_path) { // TODO: add code to use mmap std::ifstream is; is.exceptions(std::ios::badbit | std::ios::failbit); - is.open(file_name); + is.open(file_path); std::vector buffer; while(is.peek() != std::char_traits::eof()) { @@ -116,7 +116,7 @@ Source Source::load_file(std::string file_name) std::size_t contents_size = buffer.size(); auto buffer_ptr = std::make_shared>(std::move(buffer)); std::shared_ptr contents(buffer_ptr, buffer_ptr->data()); - return Source(std::move(file_name), std::move(contents), contents_size); + return Source(file_path.string(), std::move(contents), contents_size); } Source Source::load_stdin() @@ -191,4 +191,4 @@ Source::Line_and_column Source::get_line_and_column(std::size_t char_index, return Line_and_column(line_and_start_index.line, column); } } -} \ No newline at end of file +} diff --git a/src/json/source.h b/src/json/source.h index a72184f..cad2790 100644 --- a/src/json/source.h +++ b/src/json/source.h @@ -28,6 +28,7 @@ #include #include #include +#include "util/filesystem.h" namespace vulkan_cpu { @@ -96,7 +97,7 @@ struct Source { return contents != nullptr; } - static Source load_file(std::string file_name); + static Source load_file(const util::filesystem::path &file_path); static Source load_stdin(); struct Line_and_index {