42#ifndef __BASE_OUTPUT_HH__
43#define __BASE_OUTPUT_HH__
95template<
class StreamType>
116 const std::string &
name,
117 std::ios_base::openmode
mode,
127 const std::ios_base::openmode
_mode;
144 typedef std::map<std::string, OutputDirectory *>
dir_map_t;
190 std::string
resolve(
const std::string &
name)
const;
241 std::ios_base::openmode
mode,
242 bool recreateable =
true,
302 void remove(
const std::string &
name,
bool recursive=
false);
305extern OutputDirectory
simout;
Interface for creating files in a gem5 output directory.
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
~OutputDirectory()
Destructor.
std::string resolve(const std::string &name) const
Returns relative file names prepended with name of this directory.
void remove(const std::string &name, bool recursive=false)
Removes a specified file or subdirectory.
bool isFile(const std::string &name) const
Determines whether a file name corresponds to a file in this directory.
static bool isAbsolute(const std::string &name)
Test if a path is absolute.
std::string dir
Name of this directory.
static OutputStream * checkForStdio(const std::string &name)
Determines whether given file name corresponds to standard output streams.
OutputDirectory()
Constructor.
OutputDirectory * createSubdirectory(const std::string &name)
Creates a subdirectory within this directory.
static const char PATH_SEPARATOR
System-specific path separator character.
static OutputStream stdout
std::map< std::string, OutputStream * > file_map_t
File names and associated stream handles.
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).
const std::string & directory() const
Gets name of this directory.
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
dir_map_t dirs
Output sub-directories.
void setDirectory(const std::string &dir)
Sets name of this directory.
OutputStream * findOrCreate(const std::string &name, bool binary=false)
OutputStream * find(const std::string &name) const
Finds stream associated with an open file or stdout/stderr.
std::map< std::string, OutputDirectory * > dir_map_t
Output subdirectories.
static OutputStream stderr
file_map_t files
Open file streams within this directory.
void relocate(const OutputDirectory &dir) override
Re-create the file in a new location if it is relocatable.
OutputFile(const OutputDirectory &dir, const std::string &name, std::ios_base::openmode mode, bool recreateable)
bool recreateable() const override
Can the file be recreated if the output directory is moved?
stream_type_t *const _fstream
Pointer to the file stream.
const std::ios_base::openmode _mode
File mode when opened.
OutputFile(const OutputFile< StreamType > &f)
const bool _recreateable
Can the file be recreated in a new location?
std::ostream *const _stream
Underlying output stream.
virtual void relocate(const OutputDirectory &dir)
Re-create the in a new location if recreateable.
const std::string & name() const
Get the file name in the output directory.
const std::string _name
Name in output directory.
OutputStream(const std::string &name, std::ostream *stream)
Wrap an existing stream.
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.
OutputStream(const OutputStream &f)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const std::string & name()