summaryrefslogtreecommitdiff
path: root/source/fud_c_file.cpp
diff options
context:
space:
mode:
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));