|
JX Application Framework
|
#include "jFStreamUtil.h"#include "JString.h"#include <fcntl.h>#include <unistd.h>#include "jAssert.h"Functions | |
| std::fstream * | JSetFStreamLength (const JString &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.