From: Nick Sabalausky Date: 2010-03-01T17:32:18+09:00 Subject: Re: Here's a filtered file/dir copy, FWIW. Turns out there's a bug in that, but I can't figure out why... Consider this part: ---------------------------- def copy_entryx(src, dest, filter, preserve = false, dereference_root = false, remove_destination = false) Entry_.new(src, nil, dereference_root).traverse do |ent| if filter.call(ent.path) then destent = Entry_.new(dest, ent.rel, false) File.unlink destent.path if remove_destination && File.file?(destent.path) ent.copy destent.path ent.copy_metadata destent.path if preserve end end end ---------------------------- (The formatting might have gotten messed up. Check the 'copy_entryx' function in the OP's attachment for the correct formatting.) What that *should* be doing is: For each 'ent' in the traversal, check if the filter returns true, and if so, do the copy. Then, regardless of whether or not it passed the filter and was copied, move on to the next 'ent'. What is *actually* does but shouldn't do: As soon as filter returns false, instead of moving on the the next 'ent', the entire 'copy_entryx' function exits (I've checked this with debugging 'puts' statements, if I put one right on a new line right between the last two 'end' statements, it never shows unless the filter always returns true). Why does it do that, and how can I fix it? -- Posted via http://www.ruby-forum.com/.