检查文件名是文件夹还是文件


72

我有一些Ruby代码:

files.each do |file|
  FileUtils.mkdir_p(File.dirname(target))    
  FileUtils.cp_r(file, target, :verbose => true)
end

我想加一张支票

if file is a folder
  # do this
if file is a file
  # do that

如何在Ruby中实现?


1
@Jay Erm,这是Ruby,而不是Python。
安德鲁·马歇尔

1
哦,哎呀,我总是把这这两了
周杰伦

Answers:



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.