Python os.chflags() Method
Example
Set the flags of path :
#Import os and stat Library
import os,stat
#set a flag
os.chflags("/tmp/test.txt", stat.UF_IMMUTABLE)
Definition and Usage
The os.chflags() method is used to set the flags of path to the numeric flags.
Note: Available on UNIX platforms only.
Syntax
os.chflags(path, flags, follow_symlinks)
Parameter Values
| Parameter | Description |
|---|---|
| path | Required. A file path to set the flag |
| flags | Required. One or more stat module constants which might be in combination (bitwise OR), stat.UF_NODUMP - Do not dump the filestat.UF_IMMUTABLE - File may not be changed(read-only)stat.UF_APPEND - File may only be appended tostat.UF_OPAQUE - Directory is opaque, view through a union stackstat.UF_NOUNLINK - The file may not be renamed or deletedstat.UF_COMPRESSED - The file is stored compressed (Mac OS X 10.6+)stat.UF_HIDDEN - The file should not be displayed in a GUI (Mac OS X 10.5+)stat.SF_ARCHIVED - The file may be archivedstat.SF_IMMUTABLE - The file may not be changedstat.SF_APPEND - The file may only be appended tostat.SF_NOUNLINK - The file may not be renamed or deletedstat.SF_SNAPSHOT - The file is a snapshot file |
| follow_symlinks | Optional. Default value is TRUE. Set it to FALSE to not follow symlinks |
Technical Details
| Return Value: | None |
|---|---|
| Python Version: | 2.6 |
| Change Log: | 3.3: Added the follow_symlinks parameter 3.6: Accepts a path-like object |