使用python,当文件位于网络共享(从Windows2003服务器提供服务)上时,将文件设置为只读的正确方法是什么?
我在OSX(10.6.1)中运行python 2.6.2。
当路径为本地时,以下代码将引发异常(如预期),但
os.chmod
当路径指向Windows共享时似乎没有效果。
import os, stat
path = '/Volumes/Temp/test.txt'
# Create a test file.
open(path, 'w').close()
# Make the file read-only.
os.chmod(path, stat.S_IREAD)
# Try writing to it again. This should fail.
open(path, 'w').close()