From a792cfaca78efaf21661b34848dfce6458674b6d Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 18 Jul 2013 19:09:18 -0400 Subject: [PATCH] update save to file to take fc::path --- include/fc/io/json.hpp | 9 ++++++++- src/io/json.cpp | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/fc/io/json.hpp b/include/fc/io/json.hpp index 4950a87..2117fd0 100644 --- a/include/fc/io/json.hpp +++ b/include/fc/io/json.hpp @@ -25,7 +25,14 @@ namespace fc static variant from_string( const string& utf8_str ); static string to_string( const variant& v ); static string to_pretty_string( const variant& v ); - static void save_to_file( const variant& v, const string& fi, bool pretty = true ); + + template + static void save_to_file( const T& v, const fc::path& fi, bool pretty = true ) + { + save_to_file( variant(v), fi, pretty ); + } + + static void save_to_file( const variant& v, const fc::path& fi, bool pretty = true ); static variant from_file( const fc::path& p ); template diff --git a/src/io/json.cpp b/src/io/json.cpp index f280447..db667de 100644 --- a/src/io/json.cpp +++ b/src/io/json.cpp @@ -533,9 +533,9 @@ namespace fc return pretty_print(to_string(v), 2); } - void json::save_to_file( const variant& v, const string& fi, bool pretty ) + void json::save_to_file( const variant& v, const fc::path& fi, bool pretty ) { - fc::ofstream o( fi.c_str() ); + fc::ofstream o( fi.generic_string().c_str() ); fc::to_stream( o, v ); } variant json::from_file( const fc::path& p )