That covers the case of copying files locally. But let's not forget why we came on this journey. We need to be able to copy files from a remote folder.
Writing a unit test for remote file copying seems problematic. The problem would be that we cannot create a test where we can fully expect repeatable access to a remote machine. At this time the best option may be to test manually. Since we already have a method that creates copies just fine on a local system, let's see how it behaves when we try to fetch a file from a remote system.
Open up a FileList and navigate over to the remote system. Try copying the file...
Create these 2 new instance methods in ServerDirectory:
Let's see if that takes care of things. Bring the Debugger back. Make sure you have the #copySelectedFileToDirectory: method selected in the Debugger and hit "Restart" and then "Proceed".
copyFile: fileStream1 toFile: fileStream2
| buffer |
buffer := String new: 50000.
whileFalse: [fileStream2 nextPutAll: (fileStream1 nextInto: buffer)]
copyFileNamed: fileName toDirectory: aDirectory
"Copy the contents of the existing file into a directory."
| file1 file2 |
self = aDirectory ifTrue: [^ nil].
file1 := (self readOnlyFileNamed: fileName) binary.
file2 := (aDirectory newFileNamed: fileName) binary.
self copyFile: file1 toFile: file2.
Continue on to the next page of second FileList enhancement.
Back to the beginning of this example.