Ruby FileUtils.chmod in Windows

被刻印的时光 ゝ 提交于 2019-12-11 09:28:04

问题


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")

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


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/10933228/ruby-fileutils-chmod-in-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!