Top  Previous  Next

Scripts > Class elements and c++ instructions > File handling > load_file




bool load_file(str& xs, const str& xsFileName)

bool load_file(str& xs, const str& xsFileName)




Opens the file with the name xsFileName and reads the content into the string xs. true will be returned, if this process was successful, otherwise false will be returned

If the command load_file is used, the file is opened in the text mode, i.e. under Windows, that that all CR/LF combinations (carriage return/line feed) are translated into a single LF character. This is not the case, if the file is read in the binary mode with load_file_binary.





str s;

str sFileName = "C:\\Programme\\TextTransformer\\Beispiele\\Atari1\\test.txt";


if( load_file( s, sFileName) )

out << "file size : " << s.size();


out << "could not read file: " << sFileName;



Caution with cyclic Include files. If two files include each other directly or indirectly a serious abnormal end of the TextTransformer can happen. To avoid this danger, the opened files should be logged and a file only should be opened, when it isn't already open.

This page belongs to the TextTransformer Documentation

Home  Content  German