Purpose
DosSetPathInfo sets information for a file or directory.
Syntax
#define INCL DOSFILEMGR #include os2.h
APIRET DosSetPathInfo
Parameters
pszPathName PSZ) input
Global file-name characters are not permitted.
DosQuerySysInfo is called by an application during initialization to determine the maximum path length allowed by the operating system.
A value of 1, 11, or 2 can be specified, as shown in the following list.
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 extended attribute (EA) name/value pairs.
Input
If flOptions is 0x00000010 (DSPI_WRTTHRU), then all the information, including extended attributes (EAs), must be written to the disk before returning to the application. This guarantees that the EAs have been written to the disk. All other bits are reserved, and must be zero.
Returns
ulrc APIRET) returns
DosSetPathInfo returns one of the following values
32
Remarks
To use DosSetPathInfo to set any level of file information for a file or subdirectory, a process must have exclusive write access to the closed file object. Thus, if the file object is already accessed by another process, any call to DosSetPathInfo will fail.
A value of 0 in the date and time components of a field causes that field to be left unchanged. 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, then both attributes of the file are set to the new values.
For data integrity purposes, the Write-Through bit in flOptions should be used only to write the extended attributes to the disk immediately, instead of caching them and writing them later. Having the Write-Through bit set constantly can degrade performance.
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 directory named HIDEME , makes it hidden, and finally deletes it.
#define INCL_DOSFILEMGR /* File Manager values */#define INCL_DOSERRORS /* DOS Error values */ #include os2.h #include stdio.h #include string.h int main(VOID) UCHAR achNewDir 256 = "\\HIDEME"; /* Directory name */ FILESTATUS3 fsts3PathInfo = 0 ; /* Directory info */ ULONG ulBufferSize = sizeof(FILESTATUS3); /* Buffer size */ APIRET rc = NO_ERROR; /* Return code */ rc = DosCreateDir(achNewDir, (PEAOP2) NULL); /* Create directory with no EAs */ if (rc != NO_ERROR) printf("DosCreateDir error return code = %u\n", rc); return 1; else printf("Directory %s created.\n",achNewDir); rc = DosQueryPathInfo(achNewDir, FIL_STANDARD, fsts3PathInfo, ulBufferSize); /* Get standard info */ if (rc != NO_ERROR) printf("DosQueryPathInfo error return code = %u\n", rc); return 1; fsts3PathInfo.attrFile = FILE_HIDDEN; /* Add HIDDEN attribute to path */ rc = DosSetPathInfo(achNewDir, /* Change directory info on */ FIL_STANDARD, /* the disk using the buffer */ fsts3PathInfo, /*just updated. */ ulBufferSize, DSPI_WRTTHRU ); /* Write data before returning */ if (rc != NO_ERROR) printf("DosSetPathInfo error return code = %u\n", rc); return 1; else printf("Directory %s hidden.\n",achNewDir); /* Delete the hidden directory. If this step is omitted, the directory can still be manipulated by standard OS/2 commands like CHDIR and RMDIR, it will just not be displayed in a DIR command without the /AH display option specified. */ rc = DosDeleteDir (achNewDir); if (rc != NO_ERROR) printf ("DosDeleteDir error return code = %u\n", rc); return 1; else printf("Directory %s deleted.\n",achNewDir); return NO_ERROR;