32 log(
" write_file [options] output_file [input_file]\n");
34 log(
"Write the text fron the input file to the output file.\n");
37 log(
" Append to output file (instead of overwriting)\n");
40 log(
"Inside a script the input file can also can a here-document:\n");
42 log(
" write_file hello.txt <<EOT\n");
43 log(
" Hello World!\n");
49 bool append_mode =
false;
50 std::string output_filename;
53 for (argidx = 1; argidx < args.size(); argidx++)
55 if (args[argidx] ==
"-a") {
62 if (argidx < args.size() && args[argidx].rfind(
"-", 0) != 0)
63 output_filename = args[argidx++];
69 FILE *of = fopen(output_filename.c_str(), append_mode ?
"a" :
"w");
70 char buffer[64 * 1024];
73 while (0 < (bytes =
readsome(*f, buffer,
sizeof(buffer))))
74 fwrite(buffer, bytes, 1, of);
virtual void execute(std::istream *&f, std::string filename, std::vector< std::string > args, RTLIL::Design *)
#define PRIVATE_NAMESPACE_BEGIN
#define PRIVATE_NAMESPACE_END
void log_cmd_error(const char *format,...)
int readsome(std::istream &f, char *s, int n)
#define USING_YOSYS_NAMESPACE
WriteFileFrontend WriteFileFrontend
void log(const char *format,...)
void extra_args(std::istream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)