示例#1
0
void FileMaker::make_write_outfile_string() {
	vector<string> file_vec;
	vector<string>& filevec_r = file_vec;
	std::wstring tempstring;
	std::wstring outstring;
	Options opt = Options(argc, cmdvec);
	// get the filepaths listed by user
	opt.fill_arg_vector(filevec_r);
	//iterate through the filepaths, get each string and concatenate into outstring
	for (auto filepath : file_vec){
		IO io = IO(filepath);
		tempstring = io.read_file();
		outstring += tempstring;
	}
	wstring& outstring_r = outstring;
	// OPTION s : write to standard out
	if (opt.contains("-s") || opt.contains("--stdout")){
		write_stdout(outstring_r);
	}
	// OPTION o : write to file
	else if (opt.contains("-o")){
		string outpath = opt.get_output();
		string& out_r = outpath;
		write_file(outstring_r, out_r);
	}
	// DEFAULT FILE WRITE
	else {
		//write to default filepath
		string outpath = DEFAULT_OUTPATH;
		string& out_r = outpath;
		write_file(outstring_r, out_r);
	}

}