47 #ifndef __BASE_OUTPUT_HH__
48 #define __BASE_OUTPUT_HH__
97 template<
class StreamType>
118 const std::string &
name,
119 std::ios_base::openmode
mode,
129 const std::ios_base::openmode
_mode;
146 typedef std::map<std::string, OutputDirectory *>
dir_map_t;
192 std::string
resolve(
const std::string &
name)
const;
243 std::ios_base::openmode
mode,
244 bool recreateable =
true,
304 void remove(
const std::string &
name,
bool recursive=
false);
309 #endif // __BASE_OUTPUT_HH__
bool recreateable() const override
Can the file be recreated if the output directory is moved?
virtual bool recreateable() const
Can the file be recreated if the output directory is moved?
std::ostream * stream() const
Get the output underlying output stream.
OutputDirectory * createSubdirectory(const std::string &name)
Creates a subdirectory within this directory.
virtual void relocate(const OutputDirectory &dir)
Re-create the in a new location if recreateable.
const std::string & name()
std::map< std::string, OutputDirectory * > dir_map_t
Output subdirectories.
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
OutputDirectory()
Constructor.
std::ostream *const _stream
Underlying output stream.
void setDirectory(const std::string &dir)
Sets name of this directory.
void relocate(const OutputDirectory &dir) override
Re-create the file in a new location if it is relocatable.
const bool _recreateable
Can the file be recreated in a new location?
bool isFile(const std::string &name) const
Determines whether a file name corresponds to a file in this directory.
file_map_t files
Open file streams within this directory.
const std::string _name
Name in output directory.
const std::string & name() const
Get the file name in the output directory.
const std::ios_base::openmode _mode
File mode when opened.
~OutputDirectory()
Destructor.
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
OutputStream * find(const std::string &name) const
Finds stream associated with an open file or stdout/stderr.
std::string resolve(const std::string &name) const
Returns relative file names prepended with name of this directory.
OutputFile(const OutputDirectory &dir, const std::string &name, std::ios_base::openmode mode, bool recreateable)
const std::string & directory() const
Gets name of this directory.
OutputStream * findOrCreate(const std::string &name, bool binary=false)
static OutputStream stdout
static OutputStream stderr
OutputStream(const std::string &name, std::ostream *stream)
Wrap an existing stream.
static OutputStream * checkForStdio(const std::string &name)
Determines whether given file name corresponds to standard output streams.
static bool isAbsolute(const std::string &name)
Test if a path is absolute.
std::string dir
Name of this directory.
static const char PATH_SEPARATOR
System-specific path separator character.
dir_map_t dirs
Output sub-directories.
std::map< std::string, OutputStream * > file_map_t
File names and associated stream handles.
Interface for creating files in a gem5 output directory.
stream_type_t *const _fstream
Pointer to the file stream.
OutputStream * open(const std::string &name, std::ios_base::openmode mode, bool recreateable=true, bool no_gz=false)
Open a file in this directory (optionally compressed).