FileUtils.mv adding linebreaks in Windows
Posted
by Lowgain
on Stack Overflow
See other posts from Stack Overflow
or by Lowgain
Published on 2010-04-27T22:44:28Z
Indexed on
2010/04/27
23:03 UTC
Read the original article
Hit count: 440
ruby-on-rails
|Windows
I am streaming wav data from a flash application. If I get the data and do the following:
f = File.open('c:/test.wav')
f << wav_data.pack('c'*wav_data.length)
f.close
The wav file works perfectly. If I do this:
f = Tempfile.new('test.wav')
f << wav_data.pack('c'*wav_data.length)
f.close
FileUtils.mv(f.path, 'c:/')
The file is there, but sounds all garbled. Checking in a hex editor shows that everywhere the working file had an 0A (or \n), the garbled version had 0D0A (or \r\n)
I am using this in conjuction with rails+paperclip, and am going to be using a combination of Heroku and S3 for the live app, so I am hoping this problem will solve itself, but I'd like to get this working on my local machine for the time being.
Does anybody know of any reason FileUtils.mv would be doing this, and if there is a way to change its behaviour?
© Stack Overflow or respective owner