[Newbies] pathnames

Ron Teitelbaum Ron at USMedRec.com
Tue May 2 12:19:47 UTC 2006


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 at USMedRec.com 

> -----Original Message-----
> From: Chris Kassopulo
> Sent: Monday, May 01, 2006 6:02 PM
> 
> Greetings,
> 
> I am trying to get a list of the files that are in a
> directory using:
> 
> '/home/cpulo/data' asFileName fileNames.
> 
> Inspecting this line of code shows me that the pathname
> is a ByteString which is a subclass of String.  String
> has a method called fileNames.
> 
> Three questions:
> 
> Why does the pathname evaluate as a ByteString?
> 
> Why doesn't the ByteString respond to the fileNames message?
> 
> How do I do this?
> 
> Thanks,
> Chris
> 
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners




More information about the Beginners mailing list