如何判断请求的目录是否可写?
可能的重复:
如何检查权限写入目录或文件?
我试图弄清楚是否可以确定所请求的文件目录是否可写以及当前用户是否具有写入该文件夹的正确权限。
到目前为止,我正在通过创建新目录、向其中写入临时文件并将其删除(临时文件和目录)来对请求的路径进行测试。
此操作非常有问题,因为该目录可能已经存在,并且其所有旧信息可能会丢失(当目录删除时)。
有什么想法吗? 德克萨斯...
Possible Duplicate:
How do you check for permissions to write to a directory or file?
I'm trying to figure out if it is possible to determine if a requested file directory is writable and the current user have the right permissions to write into that folder.
Till now I'm making a test for the requested path by creating new directory, writing a temp file into it and remove it (the temp file and directory).
This operation is very problematic since that directory may be exist already and all of its old information can be lost (when the directory remove).
Any idea ??
Tx...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的方法是尝试操作并让系统决定是否允许。重复系统执行的检查将非常难以正确执行。就让系统来决定吧,它才是最终的仲裁者。
The best approach is to attempt the operation and let the system decide whether or not it is allowed. Duplicating the checks that the system performs would be terribly hard to get right. Just let the system decide, it is the ultimate arbiter.