Hello Ron,
Thanks for the direction.
To get the list of filenames in a directory, I do:
"return the list of file names from a directory" aDirectory := FileDirectory on: '/home/cpulo/data'. aDirectory fileNames.
or
aDirectory := (FileDirectory on: '/home/cpulo/data') fileNames.
Without the parens the path is taken as a ByteString.
It Squeaks!
Chris
On Tue, 2006-05-02 at 08:19 -0400, Ron Teitelbaum wrote:
Hi Chris,
Welcome to the Beginners list. Like you I've had some difficulty with the file handling of Squeak. From the format of your question it appears that you are on something other then Windows but the methodology should be similar.
There are two pieces to getting at files first the directory piece.
You can access directories and enumerate entries in directories by using:
FileDirectory FileDirectory default <- will get you the directory that squeak is running in FileDirectory on: '/home/cpulo/data' <- will get you the directory specified.
From this point if you need to access files you will need to use FileStream.
For Windows we use: CrLfFileStream fileNamed: aFullPathName
Look at the hierarchy for the stream you need.
To put it all together you could get the contents of readme.txt by doing the following.
"return the contents of a file 'readme.txt' in the current directory" aDirectory := FileDirectory default. aStream := CrLfFileStream fileNamed: (aDirectory fullNameFor: 'readme.txt'). ^aStream contents.
Hope that helps.
Happy coding!
Ron Teitelbaum President / Principal Software Engineer US Medical Record Specialists Ron@USMedRec.com