load_file

Top  Previous  Next

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

 

Prototype

 

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

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

 

Description

 

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.

 

 

Example:

 

str s;

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

 

if( load_file( s, sFileName) )

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

else

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