Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
下面的代码“复制”到新目的地,并在终止后删除。基本上,代码在指定的位置进行了新的条目(硬链接),并删除当前的位置(从调用目录)。由于不涉及副本和删除,因此将保留文件的内容。
提示:强烈建议对
link
的文档进行仔细研究(尤其是错误部分)。参考:
basename - parse parse pathname组件
link - 为文件
创建一个新名称
unlink - - 删除一个名称,可能是指它所转到的文件
The code below "copies" itself to a new destination and gets deleted after termination. Basically, the code makes a new entry (hardlink) at the specified location and removes the current one (from the calling directory). The contents of the file will be preserved, since there is no copy and deletion involved.
Hint: careful study of the documenation to
link
is highly recommended (especially the ERRORS section).References:
basename - parse pathname components
link - make a new name for a file
unlink - delete a name and possibly the file it refers to