Purpose
DosProtectQueryFileInfo gets file information.
Syntax
#define INCL DOSFILEMGR #include os2.h
APIRET DosProtectQueryFileInfo
Parameters
hf HFILE) input
Specify a value
Level 1 file information
11
Level 11 file information
Level 2 file information
Level 12 file information
Level 3 file information
File information, where applicable, is at least as accurate as the most recent DosProtectClose, DosResetBuffer, DosProtectSetFileInfo, or DosSetPathInfo.
Level 1 File Information (ulInfoLevel == FIL_STANDARD)
The cbList field is an ULONG. On output, this field contains the size, in bytes, of the file s entire extended attribute (EA) set on disk. You can use this value to calculate the size of the buffer required to hold the EA information returned when a value of 3 is specified for ulInfoLevel. The buffer size is less than or equal to twice the size of the file s entire EA set on disk.
The cbList field is an ULONG. On output, this field contains the size, in bytes, of the file s entire extended attribute (EA) set on disk. You can use this value to calculate the size of the buffer required to hold the EA information returned when a value of 3 is specified for ulInfoLevel. The buffer size is less than or equal to twice the size of the file s entire EA set on disk.
Input
Returns
ulrc (APIRET) returns
DosProtectQueryFile returns one of the following values
111
Remarks
In the FAT file system, only date and time information contained in level-1 file information can be modified. Zero is returned for the creation and access dates and times.
To return information contained in any of the file information levels, DosProtectQueryFileInfo must be able to read the open file. DosProtectQueryFileInfo works only when the file is opened for read access, with a deny-write sharing mode specified for access by other processes. If another process that has specified conflicting sharing and access modes has already opened the file, any call to DosProtectOpen will fail.
DosProtectEnumAttribute returns the lengths of extended attributes. This information can be used to calculate what size pInfo needs to be to hold full-extended-attribute (FEA) information returned by DosProtectQueryFileInfo when Level 3 is specified. The size of the buffer is calculated as follows
Four bytes (for oNextEntryOffset) + One byte (for
fEA) +
One byte (for cbName) +
Two bytes (for cbValue) +
Value of cbName (for the name of the EA) +
One byte (for terminating NULL in cbName) +
Value of cbValue (for the value of the EA)
Related Functions
Example Code
This example creates a read-only file named DOSFDEL.DAT , then changes the file attributes to normal, and uses DosForceDelete to delete the file so that it can not 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;