Forum: Ruby get new files in dstdir before cp_r

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rebhan, Gilbert (Guest)
on 2007-02-27 12:37
(Received via mailing list)

i have a workflow that copies folders with FileUtils.cp_r
over to an existing cvs workspace.

As cvs CLI lacks a recursive flag for add command,
i have to add all new folders and files separately in
a spaceseparated list, i.e.

cvs add ./subfolder1 ./subfolder1/subsub1
so i have to calculate all new files.

i have tried to get the new files with =

def copy_dir(dir)
  Dir.glob("#{dir}/**/*[^coinfo.txt].*").each do | i |
     if not File.exist?("#{CVSWORKSPACE}/#{i}")
       puts "new file detected ==> #{i}"

but i get =

new file detected ==> Y:/test_deploy/4804/subfolder7/subsub7/bla.txt
new file detected ==>
new file detected ==> Y:/test_deploy/4804/subfolder7/subsub6/subsub6.txt
new file detected ==>

means the whole path, where i would need the space separated list like
that =

/subfolder7 /subfolder7/subsub7 /subfolder7/subsub7/bla.txt ...

How to achieve that ?

As i use the FileUtils.cp_r method later =
doesn't this method not already know  internally which files are new ?

Regards, Gilbert
Brian C. (Guest)
on 2007-02-27 12:46
(Received via mailing list)
On Tue, Feb 27, 2007 at 07:36:26PM +0900, Rebhan, Gilbert wrote:
> that =
> /subfolder7 /subfolder7/subsub7 /subfolder7/subsub7/bla.txt ...
> How to achieve that ?


Dir.chdir(dir) do
  Dir.glob("**/*[^coinfo.txt].*").each do |i|
    puts i
This topic is locked and can not be replied to.