Problem when copying files somehow related to REXML

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.

On Jul 22, 10:39 am, Javier Q. [email protected] 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

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

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs