John_Wu
(John Wu)
27 May 2010 02:57
1
Hi
I am having a weird problem. I have the following code.
require "fileutils"
FileUtils.cp '/path/to/file.txt', '/path/to/archive/file-date.txt'
File.open('/path/to/file.txt', 'w')
What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.
But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?
Thanks a lot!
···
--
Posted via http://www.ruby-forum.com/ .
I am having a weird problem. I have the following code.
require "fileutils"
FileUtils.cp '/path/to/file.txt', '/path/to/archive/file-date.txt'
File.open('/path/to/file.txt', 'w')
You also need to close the file.
What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.
But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?
Maybe /path/to/file.txt is a symlink or /path/to is liked to
/path/to/archive or /path/to/file.txt is really the same as
/path/to/archive/file-date.txt. Somehow I have the feeling you don't
show the real code.
Kind regards
robert
···
2010/5/27 John Wu <j_wu_76@yahoo.com>:
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
John Wu wrote:
FileUtils.cp '/path/to/file.txt', '/path/to/archive/file-date.txt'
File.open('/path/to/file.txt', 'w')
What I want to do is copy file.txt content to file-date.txt in a sub
directory, then reset file.txt to empty.
But after I run the code above, both file.txt and file-date.txt are
reset to empty file. What am I missing here?
It seems everything is ok in my computer!
···
--
Posted via http://www.ruby-forum.com/\ .