Unit 'AmigaDOS' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#morphunits]

SetFileSize

Sets the size of a file

Declaration

Source position: amigados.pas line 1951

function SetFileSize(

  fh: LongInt;

  pos: LongInt;

  mode: LongInt

):LongInt;

Arguments

mode

  

One of OFFSET_BEGINNING, OFFSET_CURRENT, or OFFSET_END.

Description

Changes the file size, truncating or extending as needed. Not all handlers may support this; be careful and check the return code. If the file is extended, no values should be assumed for the new bytes. If the new position would be before the filehandle's current position in the file, the filehandle will end with a position at the end-of-file. If there are other filehandles open onto the file, the new size will not leave any filehandle pointing past the end-of-file. You can check for this by looking at the new size (which would be different than what you requested).

The seek position should not be changed unless the file is made smaller than the current seek position. However, see Errors.

Do NOT count on any specific values to be in any extended area.

Errors

The RAM: filesystem and the normal Amiga filesystem act differently in where the file position is left after SetFileSize(). RAM: leaves you at the new end of the file (incorrectly), while the Amiga ROM filesystem leaves the seek position alone, unless the new position is less than the current position, in which case you're left at the new EOF.

The best workaround is to not make any assumptions about the seek position after SetFileSize().

See also

DosSeek

  

Set the current position for reading and writing


Documentation generated on: 2021-07-30