Python os.lchflags () method
Python OS file / directory methods
Outline
Mark os.lchflags () method is used to set the path for the digital signature, similar chflags (), but no soft links.
Supported only under Unix.
grammar
lchflags () method syntax is as follows:
os.lchflags(path, flags)
parameter
path - set the mark file path
flags - may consist of one or more markers in combination, multiple use "|" separated:
UF_NODUMP: Non-dump file
UF_IMMUTABLE: file is read-only
UF_APPEND: only the additional content file
UF_NOUNLINK: File can not be deleted
UF_OPAQUE: opaque directory, you need to see through the joint stack
SF_ARCHIVED: can archive files (super user can be set)
SF_IMMUTABLE: file is read-only (super user can be set)
SF_APPEND: files can only the additional content (super user can be set)
SF_NOUNLINK: file is not deleted (super user can be set)
SF_SNAPSHOT: snapshot file (super user can be set)
return value
This method has no return value.
Examples
The following example demonstrates lchflags () method of use:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 打开文件 path = "/var/www/html/foo.txt" fd = os.open( path, os.O_RDWR|os.O_CREAT ) # 关闭文件 os.close( fd ) # 修改文件标记 ret = os.lchflags(path, os.UF_IMMUTABLE ) print "修改文件标记成功!!"
The above program output is:
修改文件标记成功!!