swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Topics   Other Library Functions  
function  

vfs.truncate

 
 

Library: File system utilities (OMVFS)
Import: omvfs.xmd

Declaration

export external function truncate
                value file file-ref
        at      value integer absolute optional

Argument definitions

file-ref
The vfs.file object associated with the file to be truncated.
absolute
The byte position at which the file will be truncated. The number of bytes remaining in the file will be equal to the value of this parameter.


Purpose

You can use vfs.truncate to truncate a file. The following program will truncate the specified file after the 5th byte:

  import "omvfs.xmd" prefixed by vfs.
  
  process
     local vfs.file too-long
     set too-long 
      to vfs.open "c:\temp\test.txt" 
      for vfs.read-write-mode
     vfs.truncate too-long at 5

This function will always leave the file with a number of bytes equal to the specified value. To empty a file, specifiy a value of 0 or vfs.start-offset. If the value specified is greater than the current size of the file, the file will be padded with null bytes up to the specified length.

If you do not specify the absolute position at which to truncate the file, it will be truncated at the current position. You can determine the current cursor position with vfs.cursor-position.

Exceptions

The following exceptions may occur:

    Related Topics
 
Other Library Functions
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.