a method for copying a file to another directory

Mathieu vanEchtelt squeakit at hotmail.com
Mon Dec 20 15:29:00 UTC 1999


hello all,
Maybe I overlooked something, when I was for a method in the 2.6 image to 
copy a file to another directory. It's hard to believe, but I couldn't find 
one.
Two messages came very nearby:
- "FileDirectory>copyFileNamed:toFileNamed:" copies a file to another name 
in the SAME directory.
- "FileDirectory>rename:toBe:" MOVES a file to another directory.

I still can't believe it's not suplied in the 2.6 image.  Is it true, or did 
I overlook something?

Below is the method I made to do what I wanted:

FileDirectory>

copyFileNamed: aFileName toDirectory: aDir
	"Copy the contents of the file with name 'aFileName' to directory with name 
'aDir'."

	| fromFile toFile buffer |
	fromFile:= (self readOnlyFileNamed: aFileName) binary.
	toFile:=(aDir newFileNamed: aFileName) binary.
	buffer := String new: 50000.
	[fromFile atEnd] whileFalse:
		[toFile nextPutAll: (fromFile nextInto: buffer)].
	fromFile close.
	toFile close.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com





More information about the Squeak-dev mailing list