DosQueryPathInfo

Gets file information for a file or subdirectory.

Syntax
DosQueryPathInfo (pszPathName, ulInfoLevel, pInfoBuf, cbInfoBuf)

Parameters

 * pszPathName (PSZ) - input : Address of the ASCIIZ file specification of the file or subdirectory.
 * Global file-name characters can be used in the name only for level 5 file information.
 * DosQuerySysInfo is called by an application during initialization to determine the maximum path length allowed by the operating system.


 * ulInfoLevel (ULONG) - input : The level of path information required.
 * A value of 1, 2, 3, or 5 can be specified, as follows:
 * 1 FIL_STANDARD - Level 1 file information
 * 2 FIL_QUERYEASIZE - Level 2 file information
 * 3 FIL_QUERYEASFROMLIST - Level 3 file information
 * 5 FIL_QUERYFULLNAME - Level 5 file information
 * Level 4 is reserved.
 * The structures described in pInfoBuf indicate the information returned for each of these levels.


 * pInfoBuf (PVOID) - output : Address of the storage area containing the requested level of path information.
 * Path information, where applicable, is based on the most recent DosClose, DosResetBuffer, DosSetFileInfo, or DosSetPathInfo.
 * Level 1 File Information (ulInfoLevel == FIL_STANDARD): pInfoBuf contains the FILESTATUS3 data structure, in which path information is returned.
 * Level 2 File Information (ulInfoLevel == FIL_QUERYEASIZE): pInfoBuf contains the FILESTATUS4 data structure. This is similar to the Level 1 structure, with the addition of the cbList field after the attrFile field.
 * The cbList field is an unsigned 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.
 * Level 3 File Information (ulInfoLevel == FIL_QUERYEASFROMLIST): This is a subset of the EA information of the file.
 * Input: ulInfoLevel contains an EAOP2 data structure. fpGEA2List points to a GEA2 that defines the attribute names whose values are returned. The GEA2 data structures must be aligned on a doubleword boundary. Each oNextEntryOffset field must contain the number of bytes from the beginning of the current entry to the beginning of the next entry in the GEA2 list. The oNextEntryOffset field in the last entry of the GEA2 list must be zero. fpFEA2List points to a data area where the relevant FEA2 list is returned. The length field of this FEA2 list is valid, giving the size of the FEA2 list buffer. oError is ignored.
 * Output: pInfoBuf is unchanged. If an error occurs, oError points to the GEA2 entry that caused the error. The buffer pointed to by fpFEA2List is filled in with the returned information. If the buffer that fpFEA2List points to is not large enough to hold the returned information (the return code is ERROR_BUFFER_OVERFLOW), cbList is still valid, assuming there is at least enough space for it. Its value is the size, in bytes, of the file's entire EA set on disk, even though only a subset of attributes was requested. The size of the buffer required to hold the EA information is less than or equal to twice the size of the file's entire EA set on disk. Level 5 File Information (ulInfoLevel == FIL_QUERYFULLNAME)
 * Level 5 returns the fully qualified ASCIIZ name of pszPathName in pInfoBuf. pszPathName may contain global file-name characters.


 * cbInfoBuf (ULONG) - input : The length, in bytes, of pInfoBuf.

Return Code

 * ulrc (APIRET) - returns:DosQueryPathInfo returns one of the following values:
 * 0  NO_ERROR
 * 3  ERROR_PATH_NOT_FOUND
 * 32 ERROR_SHARING_VIOLATION
 * 111 ERROR_BUFFER_OVERFLOW
 * 124 ERROR_INVALID_LEVEL
 * 206 ERROR_FILENAME_EXCED_RANGE
 * 254 ERROR_INVALID_EA_NAME
 * 255 ERROR_EA_LIST_INCONSISTENT

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.

For DosQueryPathInfo to return information contained in any of the file information levels, the file object must be opened for read access, with a deny-write sharing mode specified for access by other processes. Thus, if the file object is already accessed by another process that holds conflicting sharing and access rights, a call to DosQueryPathInfo fails.

Example Code
The first example obtains information about the file "STARTUP.CMD." The second example obtains information about the directory "SYSTEM." 
 * 1) define INCL_DOSFILEMGR  /* File Manager values */
 * 2) define INCL_DOSERRORS   /* DOS error values    */
 * 3) include 
 * 4) include 

int main(VOID) { UCHAR       uchFileName[80] = "C:\\STARTUP.CMD";  /* File to manipulate   */ FILESTATUS3 fsts3ConfigInfo = ;       /* Buffer for file information */ ULONG       ulBufSize     = sizeof(FILESTATUS3);  /* Size of above buffer */ APIRET      rc            = NO_ERROR;      /* Return code                 */

rc = DosQueryPathInfo(uchFileName,  /* Path and name of file           */                          FIL_STANDARD,  /* Request standard (Level 1) info */                          &fsts3ConfigInfo, /* Buffer for file information  */                          ulBufSize);    /* Size of buffer                  */ if (rc != NO_ERROR) { printf("DosQueryPathInfo error: return code = %u\n", rc); return 1; }

printf("%s --- File size: %u bytes\n",uchFileName, fsts3ConfigInfo.cbFile); printf("Last updated: %d/%d/%d; %d:%2.2d\n",           fsts3ConfigInfo.fdateLastWrite.month,        /* Month            */            fsts3ConfigInfo.fdateLastWrite.day,          /* Day              */            (fsts3ConfigInfo.fdateLastWrite.year+1980L), /* Years since 1980 */            fsts3ConfigInfo.ftimeLastWrite.hours,        /* Hours            */            fsts3ConfigInfo.ftimeLastWrite.minutes);     /* Minutes          */

return NO_ERROR; }


 * 1) define INCL_DOSFILEMGR  /* File Manager values */
 * 2) define INCL_DOSERRORS   /* DOS error values    */
 * 3) include 
 * 4) include 

int main(VOID) { UCHAR       uchPathName[255] = "C:\\OS2\\SYSTEM"; /* Path of interest     */ FILESTATUS3 fsts3ConfigInfo = ;       /* Buffer for path information */ ULONG       ulBufSize     = sizeof(FILESTATUS3);  /* Size of above buffer */ APIRET      rc            = NO_ERROR;      /* Return code                 */

rc = DosQueryPathInfo(uchPathName,  /* Name of path                    */                          FIL_STANDARD,  /* Request standard (Level 1) info */                          &fsts3ConfigInfo, /* Buffer for information       */                          ulBufSize);       /* Size of buffer               */ if (rc != NO_ERROR) { printf("DosQueryPathInfo error: return code = %u\n", rc); return 1; }

printf("Information for subdirectory: %s:\n",uchPathName); printf("Last updated: %d/%d/%d; %d:%2.2d\n",           fsts3ConfigInfo.fdateLastWrite.month,        /* Month            */            fsts3ConfigInfo.fdateLastWrite.day,          /* Day              */            (fsts3ConfigInfo.fdateLastWrite.year+1980L), /* Years since 1980 */            fsts3ConfigInfo.ftimeLastWrite.hours,        /* Hours            */            fsts3ConfigInfo.ftimeLastWrite.minutes);     /* Minutes          */

return NO_ERROR; } 

Related Functions

 * DosClose
 * DosCreateDir
 * DosEnumAttribute
 * DosOpen
 * DosQueryFileInfo
 * DosResetBuffer
 * DosSetFileInfo
 * DosSetPathInfo