📄 fcmd.test
字号:
createfile tf1 list [catch {file rename tf1 $long} msg] $msg} [subst {1 {error renaming "tf1" to "$long": file name too long}}]test fCmd-6.9 {CopyRenameOneFile: errno == ENOENT} {unixOnly} { cleanup createfile tf1 file rename tf1 tf2 glob tf*} {tf2}test fCmd-6.10 {CopyRenameOneFile: lstat(target) == 0} { cleanup createfile tf1 createfile tf2 list [catch {file rename tf1 tf2} msg] $msg} {1 {error renaming "tf1" to "tf2": file already exists}}test fCmd-6.11 {CopyRenameOneFile: force == 0} { cleanup createfile tf1 createfile tf2 list [catch {file rename tf1 tf2} msg] $msg} {1 {error renaming "tf1" to "tf2": file already exists}}test fCmd-6.12 {CopyRenameOneFile: force != 0} { cleanup createfile tf1 createfile tf2 file rename -force tf1 tf2 glob tf*} {tf2}test fCmd-6.13 {CopyRenameOneFile: source is dir, target is file} { cleanup file mkdir td1 file mkdir td2 createfile [file join td2 td1] list [catch {file rename -force td1 td2} msg] $msg} [subst {1 {can't overwrite file "[file join td2 td1]" with directory "td1"}}]test fCmd-6.14 {CopyRenameOneFile: source is file, target is dir} { cleanup createfile tf1 file mkdir [file join td1 tf1] list [catch {file rename -force tf1 td1} msg] $msg} [subst {1 {can't overwrite directory "[file join td1 tf1]" with file "tf1"}}]test fCmd-6.15 {CopyRenameOneFile: TclpRenameFile succeeds} { cleanup file mkdir [file join td1 td2] file mkdir td2 createfile [file join td2 tf1] file rename -force td2 td1 file exists [file join td1 td2 tf1]} {1}test fCmd-6.16 {CopyRenameOneFile: TclpCopyRenameOneFile fails} { cleanup file mkdir [file join td1 td2] createfile [file join td1 td2 tf1] file mkdir td2 list [catch {file rename -force td2 td1} msg] $msg} [subst {1 {error renaming "td2" to "[file join td1 td2]": file already exists}}]test fCmd-6.17 {CopyRenameOneFile: errno == EINVAL} {!$testConfig(win32s) || ($root == "C:/")} { # Don't run this test under Win32s on a drive mounted from an NT # machine; it causes the NT machine to die. cleanup list [catch {file rename -force $root tf1} msg] $msg} [subst {1 {error renaming "$root" to "tf1": trying to rename a volume or move a directory into itself}}]test fCmd-6.18 {CopyRenameOneFile: errno != EXDEV} { cleanup file mkdir [file join td1 td2] createfile [file join td1 td2 tf1] file mkdir td2 list [catch {file rename -force td2 td1} msg] $msg} [subst {1 {error renaming "td2" to "[file join td1 td2]": file already exists}}]test fCmd-6.19 {CopyRenameOneFile: errno == EXDEV} {unixOnly} { cleanup /tmp createfile tf1 file rename tf1 /tmp glob tf* /tmp/tf1} {/tmp/tf1}test fCmd-6.20 {CopyRenameOneFile: errno == EXDEV} {pcOnly} { catch {file delete -force c:/tcl8975@ d:/tcl8975@} file mkdir c:/tcl8975@ if [catch {file rename c:/tcl8975@ d:/}] { list d:/tcl8975@ } else { set msg [glob c:/tcl8975@ d:/tcl8975@] file delete -force d:/tcl8975@ set msg }} {d:/tcl8975@}test fCmd-6.21 {CopyRenameOneFile: copy/rename: S_ISDIR(source)} {unixOnly} { cleanup /tmp file mkdir td1 file rename td1 /tmp glob td* /tmp/td*} {/tmp/td1}test fCmd-6.22 {CopyRenameOneFile: copy/rename: !S_ISDIR(source)} {unixOnly} { cleanup /tmp createfile tf1 file rename tf1 /tmp glob tf* /tmp/tf*} {/tmp/tf1}test fCmd-6.23 {CopyRenameOneFile: TclpCopyDirectory failed} {unixOnly xdev} { cleanup /tmp file mkdir td1/td2/td3 exec chmod 000 td1 set msg [list [catch {file rename td1 /tmp} msg] $msg] exec chmod 755 td1 set msg } {1 {error renaming "td1": permission denied}}test fCmd-6.24 {CopyRenameOneFile: error uses original name} {unixOnly} { cleanup file mkdir ~/td1/td2 exec chmod 000 [file join [file dirname ~] [file tail ~] td1] set msg [list [catch {file copy ~/td1 td1} msg] $msg] exec chmod 755 [file join [file dirname ~] [file tail ~] td1] file delete -force ~/td1 set msg} {1 {error copying "~/td1": permission denied}}test fCmd-6.25 {CopyRenameOneFile: error uses original name} {unixOnly} { cleanup file mkdir td2 file mkdir ~/td1 exec chmod 000 [file join [file dirname ~] [file tail ~] td1] set msg [list [catch {file copy td2 ~/td1} msg] $msg] exec chmod 755 [file join [file dirname ~] [file tail ~] td1] file delete -force ~/td1 set msg} {1 {error copying "td2" to "~/td1/td2": permission denied}}test fCmd-6.26 {CopyRenameOneFile: doesn't use original name} {unixOnly} { cleanup file mkdir ~/td1/td2 exec chmod 000 [file join [file dirname ~] [file tail ~] td1 td2] set msg [list [catch {file copy ~/td1 td1} msg] $msg] exec chmod 755 [file join [file dirname ~] [file tail ~] td1 td2] file delete -force ~/td1 set msg} "1 {error copying \"~/td1\" to \"td1\": \"[file join [file dirname ~] [file tail ~] td1 td2]\": permission denied}"test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} {unixOnly xdev} { cleanup /tmp file mkdir td1/td2/td3 file mkdir /tmp/td1 createfile /tmp/td1/tf1 list [catch {file rename -force td1 /tmp} msg] $msg} {1 {error renaming "td1" to "/tmp/td1": file already exists}}test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} {unixOnly xdev} { cleanup /tmp file mkdir td1/td2/td3 exec chmod 000 td1/td2/td3 set msg [list [catch {file rename td1 /tmp} msg] $msg] exec chmod 755 td1/td2/td3 set msg} {1 {error renaming "td1" to "/tmp/td1": "td1/td2/td3": permission denied}}test fCmd-6.29 {CopyRenameOneFile: TclpCopyDirectory passed} {unixOnly xdev} { cleanup /tmp file mkdir td1/td2/td3 file rename td1 /tmp glob td* /tmp/td1/t*} {/tmp/td1/td2}test fCmd-6.30 {CopyRenameOneFile: TclpRemoveDirectory failed} {unixOnly} { cleanup file mkdir foo/bar file attr foo -perm 040555 set msg [list [catch {file rename foo/bar /tmp} msg] $msg] set a1 {1 {can't unlink "foo/bar": permission denied}} set result [expr {$msg == $a1}] catch {file delete /tmp/bar} catch {file attr foo -perm 040777} catch {file delete -force foo} set result} {1}test fCmd-6.31 {CopyRenameOneFile: TclpDeleteFile passed} {unixOnly xdev} { catch {cleanup /tmp} file mkdir /tmp/td1 createfile /tmp/td1/tf1 file rename /tmp/td1/tf1 tf1 list [file exists /tmp/td1/tf1] [file exists tf1]} {0 1}test fCmd-6.32 {CopyRenameOneFile: copy} { cleanup list [catch {file copy tf1 tf2} msg] $msg} {1 {error copying "tf1": no such file or directory}}catch {cleanup /tmp}test fCmd-7.1 {FileForceOption: none} { cleanup file mkdir [file join tf1 tf2] list [catch {file delete tf1} msg] $msg} {1 {error deleting "tf1": directory not empty}}test fCmd-7.2 {FileForceOption: -force} { cleanup file mkdir [file join tf1 tf2] file delete -force tf1} {}test fCmd-7.3 {FileForceOption: --} { createfile -tf1 file delete -- -tf1} {}test fCmd-7.4 {FileForceOption: bad option} { createfile -tf1 set msg [list [catch {file delete -tf1} msg] $msg] file delete -- -tf1 set msg} {1 {bad option "-tf1": should be -force or --}}test fCmd-7.5 {FileForceOption: multiple times through loop} { createfile -- createfile -force file delete -force -force -- -- -force list [catch {glob -- -- -force} msg] $msg} {1 {no files matched glob patterns "-- -force"}}test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} {unixOnly} { file mkdir td1 file attr td1 -perm 040000 set result [list [catch {file rename ~$user td1} msg] $msg] file delete -force td1 set result} "1 {error renaming \"~$user\" to \"td1/[file tail ~$user]\": permission denied}"test fCmd-9.1 {file rename: comprehensive: EACCES} {unixOnly} { cleanup file mkdir td1 file mkdir td2 file attr td2 -perm 040000 set result [list [catch {file rename td1 td2/} msg] $msg] file delete -force td2 file delete -force td1 set result} {1 {error renaming "td1" to "td2/td1": permission denied}}test fCmd-9.2 {file rename: comprehensive: source doesn't exist} { cleanup list [catch {file rename tf1 tf2} msg] $msg} {1 {error renaming "tf1": no such file or directory}}test fCmd-9.3 {file rename: comprehensive: file to new name} { cleanup createfile tf1 createfile tf2 testchmod 444 tf2 file rename tf1 tf3 file rename tf2 tf4 list [lsort [glob tf*]] [file writable tf3] [file writable tf4]} {{tf3 tf4} 1 0} test fCmd-9.4 {file rename: comprehensive: dir to new name} {unixOrPc} { cleanup file mkdir td1 td2 testchmod 555 td2 file rename td1 td3 file rename td2 td4 list [lsort [glob td*]] [file writable td3] [file writable td4]} {{td3 td4} 1 0} test fCmd-9.5 {file rename: comprehensive: file to self} { cleanup createfile tf1 tf1 createfile tf2 tf2 testchmod 444 tf2 file rename -force tf1 tf1 file rename -force tf2 tf2 list [contents tf1] [contents tf2] [file writable tf1] [file writable tf2]} {tf1 tf2 1 0} test fCmd-9.6 {file rename: comprehensive: dir to self} {unixOrPc} { cleanup file mkdir td1 file mkdir td2 testchmod 555 td2 file rename -force td1 . file rename -force td2 . list [lsort [glob td*]] [file writable td1] [file writable td2]} {{td1 td2} 1 0} test fCmd-9.7 {file rename: comprehensive: file to existing file} { cleanup createfile tf1 createfile tf2 createfile tfs1 createfile tfs2 createfile tfs3 createfile tfs4 createfile tfd1 createfile tfd2 createfile tfd3 createfile tfd4 testchmod 444 tfs3 testchmod 444 tfs4 testchmod 444 tfd2 testchmod 444 tfd4 set msg [list [catch {file rename tf1 tf2} msg] $msg] file rename -force tfs1 tfd1 file rename -force tfs2 tfd2 file rename -force tfs3 tfd3 file rename -force tfs4 tfd4 list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4] } {{tf1 tf2 tfd1 tfd2 tfd3 tfd4} {1 {error renaming "tf1" to "tf2": file already exists}} 1 1 0 0}test fCmd-9.8 {file rename: comprehensive: dir to empty dir} { # Under unix, you can rename a read-only directory, but you can't # move it into another directory. cleanup file mkdir td1 file mkdir [file join td2 td1] file mkdir tds1 file mkdir tds2 file mkdir tds3 file mkdir tds4 file mkdir [file join tdd1 tds1] file mkdir [file join tdd2 tds2] file mkdir [file join tdd3 tds3] file mkdir [file join tdd4 tds4] if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { testchmod 555 tds3 testchmod 555 tds4 } if {$tcl_platform(platform) != "macintosh"} { testchmod 555 [file join tdd2 tds2] testchmod 555 [file join tdd4 tds4] } set msg [list [catch {file rename td1 td2} msg] $msg] file rename -force tds1 tdd1 file rename -force tds2 tdd2 file rename -force tds3 tdd3 file rename -force tds4 tdd4 if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { set w3 [file writable [file join tdd3 tds3]] set w4 [file writable [file join tdd4 tds4]] } else { set w3 0 set w4 0 } list [lsort [glob td*]] $msg [file writable [file join tdd1 tds1]] \ [file writable [file join tdd2 tds2]] $w3 $w4} [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4} {1 {error renaming "td1" to "[file join td2 td1]": file already exists}} 1 1 0 0}]test fCmd-9.9 {file rename: comprehensive: dir to non-empty dir} { cleanup file mkdir tds1 file mkdir tds2 file mkdir [file join tdd1 tds1 xxx] file mkdir [file join tdd2 tds2 xxx] if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { testchmod 555 tds2 } set a1 [list [catch {file rename -force tds1 tdd1} msg] $msg] set a2 [list [catch {file rename -force tds2 tdd2} msg] $msg] if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { set w2 [file writable tds2] } else { set w2 0 } list [lsort [glob td*]] $a1 $a2 [file writable tds1] $w2} [subst {{tdd1 tdd2 tds1 tds2} {1 {error renaming "tds1" to "[file join tdd1 tds1]": file already exists}} {1 {error renaming "tds2" to "[file join tdd2 tds2]": file already exists}} 1 0}]test fCmd-9.10 {file rename: comprehensive: file to new name and dir} { cleanup createfile tf1 createfile tf2 file mkdir td1 testchmod 444 tf2 file rename tf1 [file join td1 tf3] file rename tf2 [file join td1 tf4] list [catch {glob tf*}] [lsort [glob [file join td1 t*]]] \ [file writable [file join td1 tf3]] [file writable [file join td1 tf4]]} [subst {1 {[file join td1 tf3] [file join td1 tf4]} 1 0}]test fCmd-9.11 {file rename: comprehensive: dir to new name and dir} { cleanup file mkdir td1 file mkdir td2 file mkdir td3 if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { testchmod 555 td2 } file rename td1 [file join td3 td3] file rename td2 [file join td3 td4] if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} { set w4 [file writable [file join td3 td4]] } else { set w4 0 } list [lsort [glob td*]] [lsort [glob [file join td3 t*]]] \ [file writable [file join td3 td3]] $w4} [subst {td3 {[file join td3 td3] [file join td3 td4]} 1 0}]test fCmd-9.12 {file rename: comprehensive: target exists} { cleanup file mkdir [file join td1 td2] [file join td2 td1] if {$tcl_platform(platform) != "macintosh"} { testchmod 555 [file join td2 td1] } file mkdir [file join td3 td4] [file join td4 td3] file rename -force td3 td4 set msg [list [file exists td3] [file exists [file join td4 td3 td4]] \ [catch {file rename td1 td2} msg] $msg] if {$tcl_platform(platform) != "macintosh"} { testchmod 755 [file join td2 td1] } set msg} [subst {0 1 1 {error renaming "td1" to "[file join td2 td1]": file already exists}}]test fCmd-9.13 {file rename: comprehensive: can't overwrite target} { cleanup file mkdir [file join td1 td2] [file join td2 td1 td4] list [catch {file rename -force td1 td2} msg] $msg} [subst {1 {error renaming "td1" to "[file join td2 td1]": file already exists}}]test fCmd-9.14 {file rename: comprehensive: dir into self} { cleanup file mkdir td1 list [glob td*] [list [catch {file rename td1 td1} msg] $msg]} [subst {td1 {1 {error renaming "td1" to "[file join td1 td1]": trying to rename a volume or move a directory into itself}}}]test fCmd-9.15 {file rename: comprehensive: source and target incompatible} { cleanup file mkdir td1 createfile tf1 list [catch {file rename -force td1 tf1} msg] $msg} {1 {can't overwrite file "tf1" with directory "td1"}}test fCmd-9.16 {file rename: comprehensive: source and target incompatible} { cleanup file mkdir td1/tf1 createfile tf1 list [catch {file rename -force tf1 td1} msg] $msg} [subst {1 {can't overwrite directory "[file join td1 tf1]" with file "tf1"}}]test fCmd-10.1 {file copy: comprehensive: source doesn't exist} { cleanup list [catch {file copy tf1 tf2} msg] $msg} {1 {error copying "tf1": no such file or directory}}test fCmd-10.2 {file copy: comprehensive: file to new name} { cleanup createfile tf1 tf1 createfile tf2 tf2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -