DFSSetDataSize

Sets file size

Local Servers:blocking
Remote Servers:N/A
NetWare Server:5.x, 6.x
Platform:NLM
Service:Direct File System

Syntax

  #include <nwdfs.h>  
   
  LONG DFSSetDataSize  (  
     LONG              handle,   
     unsigned__int64   newFileSize,   
     LONG              setSizeFlags); 
  

Parameters

handle
(IN) Specifies the handle returned from DFSsopen or DFScreat for the file on which to set the size
newFileSize
(IN) Specifies the logical byte offset at which the new end of the file is to be set
setSizeFlags
(IN) Specifes a bit in a mask indicating the ways in which the file can be expanded

Return Values

Zero on success or nonzero if an error occurs.

Remarks

DFSSetDataSize modifies the data size (end of file) for the open file identified by handle. If the file has more than one data stream, only the size of the data stream identified by handle is modified. To modify the size of more than one data stream, an application must open each stream independ ently and call DFSSetDataSize once for each data stream.

DFSSetDataSize works with the Novell Storage Services file system only. If handle specifies a file for any other system, DFSSetDataSize will not operate.

If the new size is smaller than the original size, the data at the end of the original data stream is truncated. If the new size is larger than the original size, the data size is expanded.

The setSizeFlags parameter provides some control over file expansion through the following bits:

SETSIZE_NON_SPARSE_FILE

If a file is being expanded with this bit set, it is expanded in a nonsparce manner, and data is physically allocated to the file. Blocks in such added data are zero-filled unless SETSIZE_NO_ZERO_FILL is also set. If this bit is not set the file is expanded in a sparce manner and no data is physically written to the file.

SETSIZE_NO_ZERO_FILL

With this bit set, if a file is being expanded in a nonsparce manner, newly allocated disk blocks are not zero filled. The blocks are allocated to the file but not initialized. If this bit is not set, zero-filled data is physically written from the original end of the file to the new end.

This bit is allowed only from the NLM application running on the local server and cannot be set by an NCP operation.

SETSIZE_UNDO_ON_ERR

If an error occurs during file expansion, an error is returned and the file is restored to its original size as though no expansion had taken place. If this bit is not set and an error occurs during expansion, the remaining expansion is aborted, and any partially completed expansion remains part of the file.

SETSIZE_PHYSICAL_ONLY

Only the physical end of the file is changed. The logical end is untouched. File expansion with this bit set is done in a nonsparce manner as though SETSIZE_NON_SPARSE_FILE were set. Truncation is likewise only physical, with no change to the logical end of the file.

SETSIZE_LOGICAL_ONLY

With this bit set, DFSSetDataSize changes only the logical end of the file. Allocated physical storage is neither expanded nor truncated, but remains unchanged.

See Also

DFScreat, DFSSetEndOfFile, DFSsopen