Forum: Ruby get new files in dstdir before cp_r

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C6ec9468bab19475922dd29d00714da8?d=identicon&s=25 Rebhan, Gilbert (Guest)
on 2007-02-27 11:37
(Received via mailing list)
Hi,

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
./subfolder1/subsub1/subsub.txt
so i have to calculate all new files.

i have tried to get the new files with =

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

but i get =

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

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
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (Guest)
on 2007-02-27 11: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 ?

Try:

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