Purpose
DosProtectSetFileSizeL changes the size of a file.
Syntax
#define INCL DOSFILEMGR #include os2.h
APIRET DosProtectSetFileSizeL
Parameters
hFile HFILE) input
Returns
ulrc APIRET) returns
DosProtectSetFileSizeL returns one of the following values
26
Remarks
When DosProtectSetFileSizeL is issued, the file must be open in a mode that allows write access.
The size of the open file can be truncated or extended. If the file size is being extended, the file system tries to allocate additional bytes in a contiguous (or nearly contiguous) space on the medium. The values of the new bytes are undefined.
Related Functions
Example Code
This example writes to a file named DOSPMAN.DAT , resets the buffer, and changes the size of the file using DosProtect functions.
#define INCL_DOSFILEMGR /* File Manager values */#define INCL_DOSERRORS /* DOS Error values */ #include os2.h #include stdio.h #include string.h int main(VOID) HFILE hfFileHandle = 0L; /* Handle for file being manipulated */ ULONG ulAction = 0; /* Action taken by DosOpenL */ FHLOCK FileHandleLock = 0; /* File handle lock */ ULONG ulWrote = 0; /* Number of bytes written by DosWrite */ UCHAR uchFileName 20 = "dospman.dat", /* Name of file */ uchFileData 4 = "DATA"; /* Data to write to file */ APIRET rc = NO_ERROR; /* Return code */ /* Open the file dosman.dat. Use an existing file or create a new */ /* one if it doesn't exist. */ rc = DosProtectOpenL(uchFileName, hfFileHandle, ulAction, (LONGLONG)4, FILE_ARCHIVED | FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, 0L, FileHandleLock); if (rc != NO_ERROR) printf("DosProtectOpenL error return code = %u\n", rc); return 1; rc = DosProtectWrite (hfFileHandle, (PVOID) uchFileData, sizeof (uchFileData), ulWrote, FileHandleLock); if (rc != NO_ERROR) printf("DosProtectWrite error return code = %u\n", rc); return 1; rc = DosResetBuffer (hfFileHandle); if (rc != NO_ERROR) printf("DosResetBuffer error return code = %u\n", rc); return 1; /* endif */ rc = DosProtectSetFileSizeL (hfFileHandle, (LONGLONG)8, FileHandleLock); if (rc != NO_ERROR) printf("DosProtectSetFileSizeL error return code = %u\n", rc); return 1; return NO_ERROR;