file copy

J

John Wu

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!
 
R

Robert Klemme

2010/5/27 John Wu said:
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
 
H

Hoodoo Wen

John said:
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!
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top