Odd Error in FileUtils with move and ENOENT

C

Charles Comstock

Note quite sure what the cause of this is but if I use the File.move
code below I get no errors, but if I use the commented out FileUtils
line then I get a whole serious of errors like this:

Exception `Errno::ENOENT' at
/home/cec/s/c/cc1/usr/lib/ruby/1.8/fileutils.rb:860 - No such file or
directory - /.autofs/home/grader/cse425gr/hw2/q9.scm

where hw2/q9.scm is where I am trying to move the directory entry d to,
so obviously it doesn't exist. I tried wrapping it in a begin/rescue as
well but it doesn't seem to allow that as they appear to be jumping
straight out of fileutils. Any idea on how to avoid this error output?

# pull directory up
dir = Dir["*"].shift
if !dir.nil? && FileTest.directory?(dir)
pwd = FileUtils.pwd
FileUtils.cd(dir) do
Dir["*"].each {|d| File.move d, ".."}
end
#FileUtils.move Dir[dir+"/*"], Dir.pwd
FileUtils.rm_rf dir
end

All I am trying to do is pull everything in a subdirectory up to the
directory above it, so any other suggestions that would fix that problem
would be appreciated.

In both cases the file does copy as it is supposed to, it just pukes all
of my screen doing it using fileutils.
Charles Comstock
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top