Hi guys. I am trying to copy files from one folder to another. The code is quite simple: frompath = File.join(fromdirectory,filename) topath = File.join(todirectory,filename) FileUtils.cp(frompath, topath) The code actually works and indeed copies the images. The problem is that right after copying them, the REXML throws the following exception: REXML::ParseException log: #<RuntimeError: Illegal character '&' in raw string "���� JFIF ��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality 85 ��C ! "$" $ ��C �� � \ " �� ��� } !1A Qa "q 2��� #B�� R��$3br� %&'() *456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������� .. So., what does REXML have to do with the code? The actual filename comes from a parsed element. The code previous to the copy does something like t his. doc = REXML::Document.new(screencontent) doc.root.each_recursive {|c| if c.name == 'File' images << c.attributes['source'] After that, I loop through the images array to get and copy all of the image files. I must insist that before throwing the exception, the files are actually copied. Thanks so much for your help in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jul-22 11:11 UTC
Re: Problem when copying files somehow related to REXML
On Jul 22, 10:39 am, Javier Quevedo <jquev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > After that, I loop through the images array to get and copy all of the > image files. > I must insist that before throwing the exception, the files are > actually copied.Could you show the entire code - it''s hard to say much from the fragments you''ve posted. Fred> > Thanks so much for your help in advance.
We had faced same type of problem while working on www.scrumpad.com , next generation scrum project management tool. In that case we have installed a gem rexml fix. that had saved us from this problem you can check that one. basically rexml is used for parsing On Jul 22, 3:39 pm, Javier Quevedo <jquev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys. > I am trying to copy files from one folder to another. > The code is quite simple: > > frompath = File.join(fromdirectory,filename) > topath = File.join(todirectory,filename) > FileUtils.cp(frompath, topath) > > The code actually works and indeed copies the images. > The problem is that right after copying them, the REXML throws the > following exception: > > REXML::ParseException > log: > #<RuntimeError: Illegal character ''&'' in raw string > " JFIF ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality > 85 > C > ! "$" $ C > \ " > } !1A Qa "q 2 #B R $3br > %&''() > *456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz.. > > So., what does REXML have to do with the code? > The actual filename comes from a parsed element. The code previous to > the copy does something like t his. > > doc = REXML::Document.new(screencontent) > doc.root.each_recursive {|c| > if c.name == ''File'' > images << c.attributes[''source''] > > After that, I loop through the images array to get and copy all of the > image files. > I must insist that before throwing the exception, the files are > actually copied. > > Thanks so much for your help in advance.
Javier Quevedo
2009-Jul-22 21:59 UTC
Re: Problem when copying files somehow related to REXML
I found the error. It was actually my mistake. Later in the code for whatever reason I was actually opening and trying to parse an image file with REXML, so it was breaking there, not in the previous part. Thank you so much for your useful replys. On Jul 22, 5:51 pm, sami <ssza...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> We had faced same type of problem while working onwww.scrumpad.com, > next generation scrum project management tool. In that case we have > installed a gemrexmlfix. that had saved us from this problem you > can check that one. > > basicallyrexmlis used for parsing > On Jul 22, 3:39 pm, Javier Quevedo <jquev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi guys. > > I am trying to copy files from one folder to another. > > The code is quite simple: > > > frompath = File.join(fromdirectory,filename) > > topath = File.join(todirectory,filename) > > FileUtils.cp(frompath, topath) > > > The code actually works and indeed copies the images. > > The problem is that right after copying them, theREXMLthrows the > > following exception: > > >REXML::ParseException > > log: > > #<RuntimeError: Illegal character ''&'' in raw string > > " JFIF ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality > > 85 > > C > > ! "$" $ C > > \ " > > } !1A Qa "q 2 #B R $3br > > %&''() > > *456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz.. > > > So., what doesREXMLhave to do with the code? > > The actual filename comes from a parsed element. The code previous to > > the copy does something like t his. > > > doc =REXML::Document.new(screencontent) > > doc.root.each_recursive {|c| > > if c.name == ''File'' > > images << c.attributes[''source''] > > > After that, I loop through the images array to get and copy all of the > > image files. > > I must insist that before throwing the exception, the files are > > actually copied. > > > Thanks so much for your help in advance.