Reference » Service classes » MFile » truncate

Elgrint::MFile::truncate(MFileSize) method

Declaration (see MFile.h):

void truncate(MFileSize cnt);

Description

Truncates an open local by cnt bytes (works only on local files).

Parameters:

Name Type Description
cnt MFileSize

The number of bytes to truncate.

Details

If this file is closed without errors, truncate generates exception 2001 and quits (if the file was closed on error, the function quits silently to prevent multiple errors).

If the file is an online file (FTP or HTTP), or if it was opened in an fmRead mode (see open), then truncate generates exception 2001 and quits. If an I/O error occurs, the function generates exception 2007 and quits. The file is closed on any error.

On success, the size of the file (as returned getSize) is decreased by cnt bytes, or becomes empty if cnt is greater than the previous file size (if cnt is 0, then there is no change, of course). The truncated data (the one beyond the new End-Of-File) is lost. If the file is truncated to the point before the file pointer (i.e. the position is beyond the new EOF), then the file pointer moves to the new End-Of-File (isEOF returns true), otherwise the position (as returned by getPos) doesn't change.

Remarks

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.