[Newbies] File system access in Squeak
Michael van der Gulik
mikevdg at gulik.co.nz
Tue Apr 17 22:45:27 UTC 2007
Navodit Kaushik wrote:
> Can anyone suggest a good package for file system access? Someone
> suggested Rio but I am not sure how to install it as it does not show
> up in the Package loader...
> I want to be able to work with the files on a ftp server and am not
> sure what to use for this. If possible an example script to connect to
> a ftp server and work with the files therein would be really helpful.
Sorry that nobody seems to have much advice for what you're trying to
do! What are you trying to do (at a higher level)? Is this commercially
important or one of your own projects? What are the files that you're
trying to move around - perhaps there's a better way of doing it?
Anyway... here's some example code for opening an ftp connection to a
remote server. This only uses classes from the basic Squeak release (in
this case, 3.10):
s := ServerDirectory new.
s fullPath: 'ftp://firstname.lastname@example.org/www'.
s password: 'wachtwoord'.
s directoryNames inspect.
To work out how to do this (I've never done it before), I:
1. Opened up a Browser, right-clicked on the categories pane and chose
"find class...", searching for "ftp".
2. Found the "FTPClient class", read the class comment which says to
look in ServerDirectory for examples.
3. Went to the ServerDirectory class, looked at the available methods. I
opened up a workspace and tried a few things.
4. I got an UndefinedObject>>errorNotIndexable error when I tried the
first time to open a connection. I looked at the code in the debugger
and realised that the "newDirName" variable in FTPClient was not set,
probably meaning I also need to set a directory before opening the
5. I went back to the ServerDirectory Browser, clicked on the "inst
vars" button and realised that there was a "directory" instance
variable. Clicking on that, I saw that it was accessed by "fullPath:".
Reading the comment in that method, I completed my code snippit.
Try running through the same process of discovery, and especially look
at the methods available in the ServerDirectory class. One of the
reasons that Squeak doesn't have much specific documentation is because
once you're familiar with the tools, you find it really doesn't need much!
More information about the Beginners