23TextFile::TextFile(monomem::MonoAllocator* pAllocator)
24: allocator(pAllocator)
25, priorUsage(pAllocator->TakeSnapshot())
37 allocator->Reset(priorUsage);
42 allocator->Reset(priorUsage);
43 Lines= allocator->Emplace<std::vector<MAString, StdContMA<MAString>>>(*allocator);
47lang::system::SystemErrors TextFile::Read(
const String& filePath,
int extraSpacePercentage)
51 std::ifstream iFile( tFilePath.Terminate() );
52 if ( !iFile.is_open() )
54 auto result= lang::system::SystemErrors(errno);
55 Log_Error(
"Error <{}: {!Q}> opening input file {!Q}", errno, result, filePath)
58 Log_Verbose(
"file {!Q} opened for reading", filePath)
62 while( !readOp.
IsEOF )
65 Lines->emplace_back( *allocator,(line.Length() * (100 + extraSpacePercentage)) / 100 + 1 );
66 Lines->back() << line;
69 Log_Info(
"File {!Q}, {} lines read", filePath, Lines->size() )
71 return lang::system::SystemErrors::OK;
74lang::system::SystemErrors TextFile::Write(const String& filePath)
78 std::ofstream oFile( tFilePath.Terminate() );
79 if ( !oFile.is_open() )
81 auto result= lang::system::SystemErrors(errno);
82 Log_Error(
"Error <{}: {!Q}> opening output file {!Q}", errno, result, filePath)
85 Log_Verbose(
"file {!Q} opened for writing", filePath)
87 for(
auto& line : *Lines )
89 oFile << line << std::endl;
91 Log_Info(
"File {!Q}, {} lines written", filePath, Lines->size() )
93 return lang::system::SystemErrors::OK;
#define Log_SetDomain(...)
alib::strings::TLocalString< character, 512 > PathString
strings::compatibility::std::TISReadLine< char > ISReadLineN
Type alias in namespace alib.
LocalString< 4096 > String4K
Type alias name for TLocalString<character,4096> .