Mariano Martinez Peck
marianopeck at gmail.com
Tue Nov 30 09:16:09 UTC 2010
Alexandre, maybe you will receive more answers if you ask directly in the
pharo mailing list instead of seaside, since Files doesn't have anything to
do with seaside ;)
On Mon, Nov 29, 2010 at 10:20 PM, alexandre bp <abalonpe at ulb.ac.be> wrote:
> Thank you very much for your help.
> The thing is that, when I first got the exception, I deleted the
> file manually in the Pharo folder so I'm pretty sure it doesn't exist.
> Maybe that when I do: "aStream := FileStream newFileNamed:filename" Pharo
> looks everywhere in my computer than it might find a file named 'test'
No, that shouldn't happen. What if you do FileDirectory defaul
does it work?
BTW..did you read Pharo by Example? Because there is a whole chapter
explaining Streams and files....I am very bad with them, I always forget how
to do trivial things and I need to check there...
> or with a part of it named which is 'test'...but the file was created in
> the Pharo folder so I assume it must look only there to find a file, no?
> 2010/11/28 Levente Uzonyi <leves at elte.hu>
> On Sat, 27 Nov 2010, alexandre bp wrote:
>>> I'm having trouble with the FileStream....
>>> I have tried several things:
>>> filename := 'test'.
>>> aStream := StandardFileStream new.
>>> 1) aStream := FileStream newFileNamed:filename.
>>> 2) aStream := filename asFilename writeStream.
>>> 1) this solution worked one time but when I tried to create other
>>> files with other names (whatever the name) I get an exception:
>>> 2) doesn't work at all. I get an exception as well:
>>> MessageNotUnderstood: ByteString>>asFilename.
>> How to use FileStreams?
>> existingReadOnlyFile := FileStream readOnlyFileNamed: 'foo'. "raises an
>> exception if the file doesn't exist"
>> existingReadableAndWriteableFile := FileStream oldFileNamed: 'foo'.
>> "raises an exception if the file doesn't exist"
>> readableAndWriteableFile := FileStream fileNamed: 'foo'. "automatically
>> creates the file if it doesn't exist"
>> newReadableAndWriteableFile := FileStream newFileNamed: 'foo'. "raises an
>> exception if the file exists"
>> newReadableAndWriteableFile := FileStream forceNewFileNamed: 'foo'.
>> "deletes the file if it exists"
>> All of these methods have a do: variant. For example:
>> FileStream readOnlyFileNamed: 'foo' do: [ :file | file contents "This will
>> close the file and return it's contents." ].
>> When to use StandardFileStream?
>> Only when you don't need character encoding or line-end conversion.
>>> I don't know what to do.... I don't understand why I have the
>>> exception FileExistsException even thought the name I give to filename
>>> is different...
>> Are you sure that the file doesn't exist? Some systems (windows and most
>> macs) are case insensitive, so if you have a file named 'TEST', then you
>> also have 'test' and 'Test', etc.
>>> Thx for your help
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
> seaside mailing list
> seaside at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the seaside