summaryrefslogtreecommitdiff
path: root/source/fud_c_file.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-16 22:25:08 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-16 22:25:08 -0500
commit53c4dcf374c66f1e9190f5a62a52d02fe11a69e6 (patch)
treeee40277c36fdba58fb06aca87b8ffa67ab5f8558 /source/fud_c_file.cpp
parentf3ac764684c64fbdd2094853a80b23e570cd5d9c (diff)
First crack at allocators.
Diffstat (limited to 'source/fud_c_file.cpp')
-rw-r--r--source/fud_c_file.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/fud_c_file.cpp b/source/fud_c_file.cpp
index a63923a..15c57ab 100644
--- a/source/fud_c_file.cpp
+++ b/source/fud_c_file.cpp
@@ -30,7 +30,10 @@ CBinaryFileResult CBinaryFile::make(const String& filename, CFileMode mode)
}
CBinaryFile binaryFile{};
- binaryFile.m_filename = filename;
+ auto copyStatus = binaryFile.m_filename.copy(filename);
+ if (copyStatus != FudStatus::Success) {
+ return CBinaryFileResult::error(copyStatus);
+ }
binaryFile.m_mode = modeResult.takeOkay();
binaryFile.m_modeFlags = mode;
return CBinaryFileResult::okay(std::move(binaryFile));
@@ -41,13 +44,16 @@ CBinaryFileResult CBinaryFile::make(const String& filename, CFileMode mode, cons
if (!filename.valid()) {
return CBinaryFileResult::error(FudStatus::InvalidInput);
}
- auto modeResult{String::makeFromCString(CBinaryFileModeFromFlags(mode), extraFlags)};
+ auto modeResult{String::makeFromCStrings(CBinaryFileModeFromFlags(mode), extraFlags)};
if (modeResult.isError()) {
return CBinaryFileResult::error(modeResult);
}
CBinaryFile binaryFile{};
- binaryFile.m_filename = filename;
+ auto copyStatus = binaryFile.m_filename.copy(filename);
+ if (copyStatus != FudStatus::Success) {
+ return CBinaryFileResult::error(copyStatus);
+ }
binaryFile.m_mode = modeResult.takeOkay();
binaryFile.m_modeFlags = mode;
return CBinaryFileResult::okay(std::move(binaryFile));
@@ -92,7 +98,10 @@ CTextFileResult CTextFile::make(const String& filename, CFileMode mode)
}
CTextFile textFile{};
- textFile.m_filename = filename;
+ auto copyStatus = textFile.m_filename.copy(filename);
+ if (copyStatus != FudStatus::Success) {
+ return CTextFileResult::error(copyStatus);
+ }
textFile.m_mode = modeResult.takeOkay();
textFile.m_modeFlags = mode;
return CTextFileResult::okay(std::move(textFile));
@@ -103,13 +112,16 @@ CTextFileResult CTextFile::make(const String& filename, CFileMode mode, const ch
if (!filename.valid()) {
return CTextFileResult::error(FudStatus::InvalidInput);
}
- auto modeResult{String::makeFromCString(CTextFileModeFromFlags(mode), extraFlags)};
+ auto modeResult{String::makeFromCStrings(CTextFileModeFromFlags(mode), extraFlags)};
if (modeResult.isError()) {
return CTextFileResult::error(modeResult);
}
CTextFile textFile{};
- textFile.m_filename = filename;
+ auto copyStatus = textFile.m_filename.copy(filename);
+ if (copyStatus != FudStatus::Success) {
+ return CTextFileResult::error(copyStatus);
+ }
textFile.m_mode = modeResult.takeOkay();
textFile.m_modeFlags = mode;
return CTextFileResult::okay(std::move(textFile));