diff options
author | Cheer Xiao <xiaqqaix@gmail.com> | 2013-01-15 16:18:03 +0800 |
---|---|---|
committer | Cheer Xiao <xiaqqaix@gmail.com> | 2013-01-17 15:55:05 +0800 |
commit | 4b6bd7cae5e731f8e2bafeabca59e5aaabd6749d (patch) | |
tree | fa8330fdeb42b37584c42fcdbf7f3c54c6d6ee2b /io.h | |
parent | 6f35792c74612f4b754125a5cfe9c96baa7854b9 (diff) |
Split out io_file_t
Diffstat (limited to 'io.h')
-rw-r--r-- | io.h | 51 |
1 files changed, 30 insertions, 21 deletions
@@ -39,24 +39,6 @@ public: int pipe_fd[2]; } param1; - - /** Second type-specific paramter for redirection */ - union - { - /** file creation flags to send to open for IO_FILE */ - int flags; - } param2; - - /** Filename IO_FILE. malloc'd. This needs to be used after fork, so don't use wcstring here. */ - const char *filename_cstr; - - /** Convenience to set filename_cstr via wcstring */ - void set_filename(const wcstring &str) - { - free((void *)filename_cstr); - filename_cstr = wcs2str(str.c_str()); - } - /** Function to create the output buffer */ void out_buffer_create() { @@ -100,15 +82,12 @@ public: io_mode(m), fd(f), param1(), - param2(), - filename_cstr(NULL), is_input(0) { } virtual ~io_data_t() { - free((void *)filename_cstr); } }; @@ -141,6 +120,36 @@ public: } }; +class io_file_t : public io_data_t +{ +public: + /** Filename, malloc'd. This needs to be used after fork, so don't use wcstring here. */ + const char *filename_cstr; + /** file creation flags to send to open */ + int flags; + + /** Convenience to set filename_cstr via wcstring */ + void set_filename(const wcstring &str) + { + free((void *)filename_cstr); + filename_cstr = wcs2str(str.c_str()); + } + + virtual void print() const; + + io_file_t(int f, const char *fname = NULL, int fl = 0) : + io_data_t(IO_FILE, f), + filename_cstr(fname ? strdup(fname) : NULL), + flags(fl) + { + } + + virtual ~io_file_t() + { + free((void *)filename_cstr); + } +}; + class io_chain_t : public std::vector<shared_ptr<io_data_t> > { public: |