File Tcl如何使用文件属性命令更改权限?

File Tcl如何使用文件属性命令更改权限?,file,tcl,File,Tcl,我想设置,当用户在写模式下双击打开的文件时(默认情况下),我想将其更改为只读 set f [open "mydata.csv" a+] file attributes "mydata.csv" -readonly 运行此操作时,文件的属性相同。只读旁边没有X或V set f [open "mydata.csv" a+] file attributes "mydata.csv" -readonly 知道我做错了什么吗?您还需要传递值以将该属性设置为,否则您只需要读取该值(这是一个常见的T

我想设置,当用户在写模式下双击打开的文件时(默认情况下),我想将其更改为只读

set f [open "mydata.csv" a+]
file attributes "mydata.csv" -readonly 
运行此操作时,文件的属性相同。只读旁边没有X或V

set f [open "mydata.csv" a+]
file attributes "mydata.csv" -readonly 


知道我做错了什么吗?

您还需要传递值以将该属性设置为,否则您只需要读取该值(这是一个常见的Tcl习惯用法)。在本例中,
-readonly
属性是布尔值的,因此您可以这样做来启用它:

file attributes "mydata.csv" -readonly true
要禁用它,请执行以下操作:

file attributes "mydata.csv" -readonly false
(您可以使用Tcl解释为布尔值的任何内容;
1
on
yes
都是
true
的别名,
0
off
no
都是
false
的别名)