Purpose
DosProtectSetFileInfo sets file information.
Syntax
#define INCL DOSFILEMGR #include os2.h
APIRET DosProtectSetFileInfo
Parameters
hf HFILE) input
Specify a value
Level 1 file information
11
Level 11 file information
Level 2 file information
Level 1 File Information (ulInfoLevel == FIL_STANDARD)
Level 2 sets a series of EA name/value pairs. On input, pInfoBuf is an EAOP2 data structure. fpGEA2List is ignored. fpFEA2List points to a data area where the relevant is an FEA2 list is to be found. oError is ignored.
On output, fpGEA2List and fpFEA2List are unchanged. The area pointed to by fpFEA2List is unchanged. If an error occurred during the set, oError is the offset of the FEA2 where the error occurred. The return code is the error code corresponding to the condition generating the error. If no error occurred, oError is undefined.
Returns
ulrc APIRET) returns
DosProtectSetFileInfo returns one of the following values
87
Remarks
DosProtectSetFileInfo is successful only when the file is opened for write access, and access by other processes is prevented by a deny-both sharing mode. If the file is already opened with conflicting sharing rights, any call to DosProtectOpen will fail.
A value of 0 in the date and time components of a field does not change the field. For example, if both last write date and last write time are specified as 0 in the Level 1 information structure, then both attributes of the file are left unchanged. If either last write date or last write time are other than 0, both attributes of the file are set to the new values.
In the FAT file system, only the dates and times of the last write can be modified. Creation and last-access dates and times are not affected.
The last-modification date and time will be changed if the extended attributes are modified.
Related Functions
Example Code
This example creates a read-only file named DOSFDEL.DAT , then changes its attributes to normal file, and finally uses DosForceDelete to delete the file so that it cannot be restored using UNDELETE.
#define INCL_DOSFILEMGR /* File Manager values */#define INCL_DOSERRORS /* DOS error values */ #include os2.h #include stdio.h int main(VOID) UCHAR uchFileName = "DOSFDEL.DAT"; /* File to delete */ HFILE fhDelFile = 0; /* File handle from DosOpenL */ FILESTATUS3L fsts3FileInfo = 0 ; /* Information associated with file */ ULONG ulBufferSize = sizeof(FILESTATUS3L); /* File info buffer size */ ULONG ulOpenAction = 0; /* Action taken by DosOpenL */ APIRET rc = NO_ERROR; /* Return code */ FHLOCK FHLock = 0; /* File handle lock */ /* Create a read-only file */ rc = DosProtectOpenL(uchFileName, fhDelFile, ulOpenAction, (LONGLONG)10, FILE_READONLY, OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L, FHLock); if (rc != NO_ERROR) printf("DosProtectOpenL error return code = %u\n", rc); return 1; rc = DosProtectQueryFileInfo(fhDelFile, FIL_STANDARDL, fsts3FileInfo, ulBufferSize, FHLock); /* Get standard info */ if (rc != NO_ERROR) printf("DosProtectQueryFileInfo error return code = %u\n", rc); return 1; else printf("File %s created read-only.\n",uchFileName); /* Change the file attributes to be "normal" */ fsts3FileInfo.attrFile = FILE_NORMAL; rc = DosProtectSetFileInfo(fhDelFile, FIL_STANDARDL, fsts3FileInfo, ulBufferSize, FHLock); if (rc != NO_ERROR) printf("DosProtectSetFileInfo error return code = %u\n", rc); return 1; rc = DosProtectClose(fhDelFile, FHLock); /* Should verify that (rc != NO_ERROR) here... *//* Delete the file */ rc = DosForceDelete(uchFileName); if (rc != NO_ERROR) printf("DosForceDelete error return code = %u\n", rc); return 1; else printf("File %s has been deleted.\n",uchFileName); /* endif */ return NO_ERROR;