Created
September 14, 2018 16:25
-
-
Save andrewcrabb/08e5717796cbdc5528dbf564715949ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/filesystem.hpp> | |
#include <boost/filesystem/path.hpp> | |
#include <boost/filesystem/fstream.hpp> | |
namespace bf = boost::filesystem; | |
int open_ostream(bf::ofstream &t_stream, bf::path t_path, std::ios_base::openmode t_mode) { | |
t_stream.open(t_path, t_mode); | |
if (!t_stream.is_open()) { | |
std::cerr << "Could not open output file " << t_path << std::endl; | |
return 1; | |
} | |
return 0; | |
} | |
int main(int argc, char **argv){ | |
std::string myname = "Andrew"; | |
std::cout << myname << std::endl; | |
bf::path my_path(argv[1]); | |
bf::path another_path; | |
std::cout << "another length: " << another_path.string().length() << std::endl; | |
std::cout << "raw: " << my_path << std::endl; | |
std::cout << "filename: " << my_path.filename() << std::endl; | |
std::cout << "stem: " << my_path.stem() << std::endl; | |
std::cout << "replace: " << my_path.replace_extension("foo") << std::endl; | |
std::cout << "raw now: " << my_path << std::endl; | |
bf::ofstream ofstr; | |
open_ostream(ofstr, my_path, std::ios::out); | |
ofstr << "Hello Andrew"; | |
// std::ofstream stdstream = open_stdstream(my_path.string()); | |
// stdstream << "Hello Andrew"; | |
std::string foo = "/foo/bar/baz.txt"; | |
bf::path other_path; | |
other_path = foo; | |
std::cout << "other: " << other_path << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment