示例#1
0
文件: write.cpp 项目: yangbenfa/readr
// [[Rcpp::export]]
void write_file_raw_(RawVector x, const std::string &path, bool append = false) {
  std::ofstream output(path.c_str(), append ? std::ofstream::app : std::ofstream::trunc);

  if (output.fail()) {
    stop("Failed to open '%s'.", path);
  }

  std::copy(x.begin(), x.end(), std::ostream_iterator<char>(output));

  return;
}