NXFileSetLength

Sets the logical end of the file.

Library:LibC
Classification:NKS
Service:File and Directory I/O

Syntax

  #include <nks/fsio.h> 
  
  int NXFileSetLength (
     NXPathCtx_t     pathCtx,
     const void     *pathname,
     NXOffset_t      length,
     unsigned long   flags);
  

Parameters

pathCtx

(IN) Specifies the file system path context. Along with the pathname parameter, it specifies the file whose length is being set.

pathname

(IN) Points to a null-terminated Unicode or ASCII string that specifies the name of the file (relative to pathCtx).

length

(IN) Specifies the new file length.

flags

(IN) Not currently used. Set to 0.

Return Values

If successful, returns 0. Otherwise, returns one of the following error codes:

Decimal

Hex

Constant

Description

1

0x01

NX_ENOENT

The specified file does not exist.

6

0x06

NX_EACCES

Insufficient access rights to the file.

9

0x09

NX_EINVAL

A pathCtx was specified, but pathname indicates a full path.

105

0x69

NX_ENOCONTEXT

The calling thread has no NKS context.

Remarks

NXFileSetLength sets the length of the file specified by the combination of pathCtx and pathname. If you know the handle by which the file was previously opened, you can call NXFileSetLengthWithHandle to set the file's length.

The actual physical size of the file can be smaller, larger, or the same as the length parameter.

See Also