threading/: - Rename 19 camelCase method files to hyphenated names - task-system: createtaskgroup→create-task-group, etc. - tasksystemconfig: enabletaskprofiling→enable-task-profiling, etc. - thread: getcurrentid→get-current-id, etc. - task: addref→add-ref, getid→get-id, etc. math/: - Rename underscore operator files to hyphenated - vector3: operator_add→operator-add, etc. - matrix4: gettranslation→get-translation, etc. - vector4: tovector3→to-vector3, constructor_vector3→constructor-vector3 - sphere: sphere_constructor→sphere-constructor, etc. memory/: - Remove duplicate memorymanager/ folder (kept manager/ which was correct) core/: - filewriter: Consolidate ctor-default.md and ctor-file.md into constructor.md - Rename dtor.md→destructor.md debug/: - filelogsink: Rename construct.md→constructor.md, ~filelogsink.md→destructor.md All overview pages updated with new file references.
1.3 KiB
1.3 KiB
FileWriter::FileWriter
重载 1: 默认构造
FileWriter();
默认构造 FileWriter 对象,不打开任何文件。
描述
创建 FileWriter 实例,m_file 初始化为 nullptr。可后续通过 Open 方法打开文件。
参数: 无
返回: 无
线程安全: ❌
复杂度: O(1)
示例:
#include <XCEngine/Core/FileWriter.h>
using namespace XCEngine::Core;
FileWriter writer;
if (!writer.IsOpen()) {
writer.Open("output.txt");
writer.Write("Hello\n");
writer.Close();
}
重载 2: 文件路径构造
FileWriter(const char* filePath, bool append = false);
构造 FileWriter 对象并打开文件。
参数:
filePath- 要打开的文件路径append- 是否以追加模式打开,默认 false(覆盖模式)
返回: 无
线程安全: ❌
复杂度: O(1)
示例:
#include <XCEngine/Core/FileWriter.h>
using namespace XCEngine::Core;
// 覆盖模式打开
FileWriter writer1("output.txt");
if (writer1.IsOpen()) {
writer1.Write("Content\n");
}
// 追加模式打开
FileWriter writer2("log.txt", true);
if (writer2.IsOpen()) {
writer2.Write("New log entry\n");
}
相关文档
- FileWriter 总览 - 返回类总览
- Open - 打开文件