Jump to content

DosSetFileMode: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
This call changes the mode (attribute) of the specified file.
This call changes the mode (attribute) of the specified file.


==Syntax==
==Syntax==
<PRE>
  DosSetFileMode (FileName, NewAttribute, Reserved)  
  DosSetFileMode
 
    (FileName, NewAttribute, Reserved)  
</PRE>


==Parameters==
==Parameters==
; FileName (PSZ) - input : Address of the file path name.
;FileName (PSZ) - input : Address of the file path name.
 
:[[DosQSysInfo]] is called by an application during initialization to determine the maximum path length allowed by OS/2.
DosQSysInfo is called by an application during initialization to determine the maximum path length allowed by OS/2.  
;NewAttribute (USHORT) - input : File's new attribute. File attributes are defined as follows:
 
::15-6 - Reserved and must be zero.
; NewAttribute (USHORT) - input : File's new attribute. File attributes are defined as follows:
::5 - File archive
 
::4 - Subdirectory
'''Bit        Description'''
::3 - Volume label
15-6       Reserved and must be zero.
::2 - System file (excluded from normal directory searches)
5       File archive
::1 - Hidden file
4       Subdirectory
::0 - Read only file
3       Volume label
:These bits may be set individually or in combination. For example, an attribute value of 0021H (bits 5 and 0 set to 1) indicates a read-only file that should be archived.
2       System file (excluded from normal directory searches)
;Reserved (ULONG) - input : Reserved must be set to zero.
1       Hidden file
0       Read only file  
 
These bits may be set individually or in combination. For example, an attribute value of 0021H (bits 5 and 0 set to 1) indicates a read-only file that should be archived.  
 
; Reserved (ULONG) - input : Reserved must be set to zero.  


==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
* 0 NO_ERROR
Return code descriptions are:
* 2 ERROR_FILE_NOT_FOUND
 
* 3 ERROR_PATH_NOT_FOUND
* 0       NO_ERROR  
* 5 ERROR_ACCESS_DENIED
* 2       ERROR_FILE_NOT_FOUND  
* 26 ERROR_NOT_DOS_DISK
* 3       ERROR_PATH_NOT_FOUND  
* 32 ERROR_SHARING_VIOLATION
* 5       ERROR_ACCESS_DENIED  
* 36 ERROR_SHARING_BUFFER_EXCEEDED
* 26       ERROR_NOT_DOS_DISK  
* 87 ERROR_INVALID_PARAMETER
* 32       ERROR_SHARING_VIOLATION  
*108 ERROR_DRIVE_LOCKED
* 36       ERROR_SHARING_BUFFER_EXCEEDED  
*206 ERROR_FILENAME_EXCED_RANGE
* 87       ERROR_INVALID_PARAMETER
* 108       ERROR_DRIVE_LOCKED  
* 206       ERROR_FILENAME_EXCED_RANGE


==Remarks==
==Remarks==
Attributes for Volume Label (0008H) and Subdirectory (0010H) cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_INVALID_PARAMETER is returned.
Attributes for Volume Label (0008H) and Subdirectory (0010H) cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_INVALID_PARAMETER is returned.


DosQFileMode is used to query the current settings for file attributes. Calling DosQFSInfo obtains volume label information.
[[DosQFileMode]] is used to query the current settings for file attributes. Calling [[DosQFSInfo]] obtains volume label information.


Attributes of root directories cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_ACCESS_DENIED is returned.  
Attributes of root directories cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_ACCESS_DENIED is returned.  


==Example Code==
==Bindings==
=== C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSFILEMGR
#define INCL_DOSFILEMGR
Line 59: Line 45:
USHORT  rc = DosSetFileMode(FileName, NewAttribute, Reserved);
USHORT  rc = DosSetFileMode(FileName, NewAttribute, Reserved);


PSZ             FileName;      /* File path name string */
PSZ     FileName;      /* File path name string */
USHORT           NewAttribute;  /* New attribute of file */
USHORT NewAttribute;  /* New attribute of file */
ULONG           0;            /* Reserved (must be zero) */
ULONG   0;            /* Reserved (must be zero) */


USHORT           rc;            /* return code */
USHORT rc;            /* return code */
</PRE>
</PRE>


===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosSetFileMode:FAR
EXTRN  DosSetFileMode:FAR
Line 79: Line 65:
</PRE>
</PRE>


==Related Functions==
[[Category:Dos]]
*
 
[[Category:The OS/2 API Project]]

Latest revision as of 02:12, 20 February 2023

This call changes the mode (attribute) of the specified file.

Syntax

DosSetFileMode (FileName, NewAttribute, Reserved) 

Parameters

FileName (PSZ) - input
Address of the file path name.
DosQSysInfo is called by an application during initialization to determine the maximum path length allowed by OS/2.
NewAttribute (USHORT) - input
File's new attribute. File attributes are defined as follows:
15-6 - Reserved and must be zero.
5 - File archive
4 - Subdirectory
3 - Volume label
2 - System file (excluded from normal directory searches)
1 - Hidden file
0 - Read only file
These bits may be set individually or in combination. For example, an attribute value of 0021H (bits 5 and 0 set to 1) indicates a read-only file that should be archived.
Reserved (ULONG) - input
Reserved must be set to zero.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 2 ERROR_FILE_NOT_FOUND
  • 3 ERROR_PATH_NOT_FOUND
  • 5 ERROR_ACCESS_DENIED
  • 26 ERROR_NOT_DOS_DISK
  • 32 ERROR_SHARING_VIOLATION
  • 36 ERROR_SHARING_BUFFER_EXCEEDED
  • 87 ERROR_INVALID_PARAMETER
  • 108 ERROR_DRIVE_LOCKED
  • 206 ERROR_FILENAME_EXCED_RANGE

Remarks

Attributes for Volume Label (0008H) and Subdirectory (0010H) cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_INVALID_PARAMETER is returned.

DosQFileMode is used to query the current settings for file attributes. Calling DosQFSInfo obtains volume label information.

Attributes of root directories cannot be changed using DosSetFileMode. If these attributes are specified, ERROR_ACCESS_DENIED is returned.

Bindings

C

#define INCL_DOSFILEMGR

USHORT  rc = DosSetFileMode(FileName, NewAttribute, Reserved);

PSZ     FileName;      /* File path name string */
USHORT  NewAttribute;  /* New attribute of file */
ULONG   0;             /* Reserved (must be zero) */

USHORT  rc;            /* return code */

MASM

EXTRN  DosSetFileMode:FAR
INCL_DOSFILEMGR     EQU 1

PUSH@  ASCIIZ  FileName      ;File path name string
PUSH   WORD    NewAttribute  ;New attribute of file
PUSH   DWORD   0             ;Reserved (must be zero)
CALL   DosSetFileMode

Returns WORD