swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax     Other Library Functions  
function  

vfs.truncate

 
 

Library: General, 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 Syntax
   vfs.open
   vfs.file
 
  Other Library Functions
   vfs.change-directory
   vfs.change-owner
   vfs.change-permissions
   vfs.close
   vfs.connect
   vfs.connect-directory
   vfs.copy
   vfs.cursor-position
   vfs.default-certificates-file
   vfs.delete-directory
   vfs.delete-file
   vfs.describe
   vfs.describe-file
   vfs.directory
   vfs.directory-name
   vfs.disconnect
   vfs.file
   vfs.file-directory
   vfs.file-name
   vfs.link
   vfs.list
   vfs.lock
   vfs.make-directory
   vfs.move
   vfs.move-cursor
   vfs.omvfs-version
   vfs.open
   vfs.open-file-system
   vfs.open-ftp
   vfs.open-http
   vfs.open-https
   vfs.reader
   vfs.set-default-certificates-file
   vfs.truncate
   vfs.unlock
   vfs.writer
 
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:46:03 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.