Windows中的Ruby FileUtils.chmod [英] Ruby FileUtils.chmod in Windows

查看:85
本文介绍了Windows中的Ruby FileUtils.chmod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个Ruby脚本,可以在其中随意移动文件,并且在其中的某个点上,我需要设置某些文件的权限,以便从UNIX计算机上查看时,权限可以准确地反映出来。问题是,我是从Windows 64位计算机上运行脚本的,当我从UNIX计算机上查看文件时,似乎对文件没有任何影响。

So I have a Ruby script where I am moving files around and whatnot and, at a point in it, I need to set the permissions for some files so that when viewed from a UNIX machine, the permissions are being reflected accurately. The problem is, I am running the script from a Windows 64-bit machine and it doesn't seem to have any effect on the files when I view them from the UNIX machine.

这是我的权限示例代码:

Here is my example code for the permissions:

FileUtils.chmod(0777, "file")

这似乎对文件的影响为零。在UNIX中检查它时,它具有 rw-rw-r 权限。

And that seems to have zero effect on the file. When I check it in UNIX, it has permissions rw-rw-r.

推荐答案

File.chmod 在Windows上是无操作操作,因为NTFS或FAT都不支持这种权限。

File.chmod is a no-op operation on Windows since neither NTFS or FAT support that kind of permissions.

更糟糕的是,Windows通过Samba(SMB)文件共享将不会知道您要修改的文件位于UNIX环境中。

Even worse, Windows, through Samba (SMB) file sharing will not know that the files you're trying to modify are located in an UNIX environment.

如果需要应用类似UNIX的权限,则需要从在UNIX操作系统上运行的Ruby版本执行该操作。

If you need to apply UNIX-like permissions, then you will need to perform that operation from a version of Ruby running on a UNIX operating system.

这篇关于Windows中的Ruby FileUtils.chmod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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