有没有Ruby类/方法可以让我传递“完整路径”home/me/a_file.txt
来识别它是否是一个有效的文件路径?
发布于 2011-12-21 20:53:26
请查看Pathname,特别是Pathname#exist?
。
发布于 2011-12-21 20:52:41
# file? will only return true for files
File.file?(filename)
和
# Will also return true for directories - watch out!
File.exist?(filename)
https://stackoverflow.com/questions/8590098
复制相似问题