get new files in dstdir before cp_r

R

Rebhan, Gilbert

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 =3D

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

but i get =3D

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

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

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


How to achieve that ?

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


Regards, Gilbert
 
B

Brian Candler

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 ?

Try:

Dir.chdir(dir) do
Dir.glob("**/*[^coinfo.txt].*").each do |i|
puts i
end
end
 

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

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top