Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <io.h>
    int chsize( int handle, long size );

Description:
    The chsize function changes the size of the file associated with handle
    by extending or truncating the file to the length specified by size.  If
    the file needs to be extended, the file is padded with NULL ('\0')
    characters.

Returns:
    The chsize function returns zero if successful.  A return value of -1
    indicates an error, and  errno is set to indicate the error.

Errors:
    When an error has occurred,  errno contains a value indicating the type
    of error that has been detected.

    EBADF
        Invalid file handle.

    ENOSPC
        Not enough space left on the device to extend the file.


See Also:
    close, creat, open

Example:
    #include <stdio.h>
    #include <io.h>
    #include <fcntl.h>
    #include <sys\stat.h>

    void main()
      {
        int  handle;

        handle = open( "file", O_RDWR | O_CREAT,
                    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
        if( handle != -1 ) {
          if( chsize( handle, 32 * 1024L ) != 0 ) {
              printf( "Error extending file\n" );
          }
          close( handle );
        }
      }

Classification:
    WATCOM

Systems:
    All

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson