I am using Ruby and need to detect whether a directory is writeable before trying to create new files.
I have tried the following code, which correctly returns true/false depending on whether @path is a directory. However, it still returns true when there is no write permission to the @path folder.
if File.directory?(@path) && File.writable?(@path)
#is a writeable directory
true
else
#is not a writeable directory
false
end
I have looked at the help for the File and Dir classes and cannot see any method that allows me to check directory write permissions. Is there a way?
I only need it work on Windows, using Ruby 1.9.3.