JX Application Framework
|
Functions | |
void | JReadFile (const JString &fileName, JString *str) |
void | JReadFile (std::ifstream &input, JString *str) |
void | JReadFile (std::fstream &input, JString *str) |
JSize | JGetFStreamLength (std::ifstream &theStream) |
JSize | JGetFStreamLength (std::fstream &theStream) |
std::fstream * | JSetFStreamLength (const char *fileName, std::fstream &originalStream, const JSize newLength, const JFStreamOpenMode io_mode) |
std::fstream * | JSetFStreamLength (const JString &fileName, std::fstream &originalStream, const JSize newLength, const JFStreamOpenMode io_mode) |
bool | JConvertToStream (const int input, std::ifstream *input2, JString *tempFullName, const bool closeInput=true) |
bool JConvertToStream | ( | const int | input, |
std::ifstream * | input2, | ||
JString * | tempFullName, | ||
const bool | closeInput | ||
) |
Convert the data from the given file descriptor into an std::ifstream. The location of the file is returned in tempFullName.
This would be unnecessary if libstdc++ provided a stream wrapper for arbitrary file descriptors.
JSize JGetFStreamLength | ( | std::fstream & | theStream | ) |
JSize JGetFStreamLength | ( | std::ifstream & | theStream | ) |
Returns the length of the file associated with theStream.
Read characters from the std::fstream until the end of the file is reached. These functions takes a JString* because the contents of the file could be very large, and returning a JString requires twice as much memory because of the copy constructor.
These are equivalent to JReadAll() in jStreamUtil.h, except that they are optimized to work with file streams.
void JReadFile | ( | std::fstream & | input, |
JString * | str | ||
) |
void JReadFile | ( | std::ifstream & | input, |
JString * | str | ||
) |
std::fstream * JSetFStreamLength | ( | const char * | fileName, |
std::fstream & | originalStream, | ||
const JSize | newLength, | ||
const JFStreamOpenMode | io_mode | ||
) |
std::fstream * JSetFStreamLength | ( | const JString & | fileName, |
std::fstream & | originalStream, | ||
const JSize | newLength, | ||
const JFStreamOpenMode | io_mode | ||
) |
Sets the length of the file associated with originalStream.
The only efficient way is to use ftruncate(), which requires a file descriptor. Since we can't get this from the stream, we require the file name. Once we operate on the descriptor, the stream will be hopelessly confused, so we have to close it first. This is why we return a jnew one afterwards.
The caller is responsible for deleting originalStream.