swebb2066 commented on code in PR #775:
URL: https://github.com/apache/logging-log4cxx/pull/775#discussion_r4253911277
##########
src/main/cpp/fileoutputstream.cpp:
##########
@@ -28,27 +29,46 @@ using namespace LOG4CXX_NS::helpers;
struct FileOutputStream::FileOutputStreamPrivate
{
FileOutputStreamPrivate(const LogString& filename)
- : path(filename)
+ : path(filename), logappend(false), filename(filename)
{}
File path;
Pool pool;
apr_file_t* fileptr{ nullptr };
+ bool logappend;
+ LogString filename;
void open(bool append);
+ void openAsTruncatedIfAlreadyExists(bool append);
};
IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream)
FileOutputStream::FileOutputStream(const LogString& filename, bool append)
: m_priv(std::make_unique<FileOutputStreamPrivate>(filename))
{
- m_priv->open(append);
+ m_priv->logappend = append;
+ m_priv->path = filename;
+
+ // Tests expect that existing files are truncated even if
+ // nothing is logged.
+ if (!append)
+ {
+ m_priv->openAsTruncatedIfAlreadyExists(append);
+ }
}
FileOutputStream::FileOutputStream(const logchar* filename, bool append)
: m_priv(std::make_unique<FileOutputStreamPrivate>(filename))
{
- m_priv->open(append);
+ m_priv->logappend = append;
+ m_priv->path = filename;
Review Comment:
path is assigned in the FileOutputStreamPrivate constructor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]