Add support for "yosys -E"
[yosys.git] / passes / cmds / write_file.cc
index 813e215ba04fe5ad2ea0b46e19f247e5d3a63244..70892a945b72cfd175a3e3457816b8b6ee235808 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "kernel/yosys.h"
 
+USING_YOSYS_NAMESPACE
+PRIVATE_NAMESPACE_BEGIN
+
 struct WriteFileFrontend : public Frontend {
        WriteFileFrontend() : Frontend("=write_file", "write a text to a file") { }
        virtual void help()
@@ -28,7 +31,7 @@ struct WriteFileFrontend : public Frontend {
                log("\n");
                log("    write_file [options] output_file [input_file]\n");
                log("\n");
-               log("Write the text fron the input file to the output file.\n");
+               log("Write the text from the input file to the output file.\n");
                log("\n");
                log("    -a\n");
                log("        Append to output file (instead of overwriting)\n");
@@ -64,13 +67,15 @@ struct WriteFileFrontend : public Frontend {
                extra_args(f, filename, args, argidx);
 
                FILE *of = fopen(output_filename.c_str(), append_mode ? "a" : "w");
+               yosys_output_files.insert(output_filename);
                char buffer[64 * 1024];
-               size_t bytes;
+               int bytes;
 
-               while (0 < (bytes = f->readsome(buffer, sizeof(buffer))))
+               while (0 < (bytes = readsome(*f, buffer, sizeof(buffer))))
                        fwrite(buffer, bytes, 1, of);
 
                fclose(of);
        }
 } WriteFileFrontend;
 
+PRIVATE_NAMESPACE_END