UNIX“cp -pL"的 Tcl 等效项命令 [英] Tcl equivalent for UNIX "cp -pL" command

查看:34
本文介绍了UNIX“cp -pL"的 Tcl 等效项命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UNIX "cp -pL" 命令的 Tcl 等价物是什么?我在文件命令描述

What is Tcl equivalent for UNIX "cp -pL" command? I cannot find it in file command description

推荐答案

对于单个文件:a) 获取文件的真实路径.b) 复制它.c) 设置属性、修改时间和访问时间.

For a single file: a) Get the real path to the file. b) Copy it. c) Set the attributes, modification time and access time.

不幸的是,似乎没有任何方法可以设置更改时间(Windows 上的创建时间).

Unfortunately, there does not appear to be any way to set the change time (creation time on Windows).

set fn sourcefn
set tofn targetfn
set nfn [file normalize [file readlink $fn]]
file copy -force $nfn $tofn
foreach {key} [list attributes mtime atime] {
  set temp [file $key $nfn]
  file $key $tofn {*}$temp
}

这是适用于 unix、Mac OS X 和 Windows 的纯 Tcl 解决方案.当然你可以这样做:

This is the pure Tcl solution that will work on unix, Mac OS X and Windows. Of course you could just do:

exec cp -pLf $from $to

参考:文件

这篇关于UNIX“cp -pL"的 Tcl 等效项命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆