I have a feeling that you are working on the wrong level, consider:

file := FileReference newTempFilePrefix: 'data' suffix: '.txt'.
file writeStreamDo: [ :out | out << 'Casimiro de Almeida Barreto' ].
file contents.
file ensureDelete.
file exists.

The #newTempFilePrefix:suffix: method uses 'FileLocator temp' as target 
directory, which will be different on different platforms.

The trick is to use these FileLocator locations, try 'FileLocator 
supportedOrigins', to have an abstract, cross platform starting point (except 
for the Windows drives, obviously). Then you construct directories using 
messages.

Remember, the whole image, file browser, file dialogs, they all work cross 
platform, so you can do so too. 

> On 30 Apr 2017, at 21:37, Casimiro de Almeida Barreto 
> <casimiro.barr...@gmail.com> wrote:
> 
>> Clear example follows. By the way ‘/’ and ‘\’ are not interchangeable… in 
>> Windows FileSystem requires ‘\’ to work properly:
>> 
>>  
>> 
>> | fn l fileStream |
>> 
>> fn := 'temp\',UUIDGenerator next asString,'.txt'.
>> 
>> Transcript clear; show: fn; cr.
>> 
>> fileStream := ((FileSystem root) / fn) writeStream.
>> 
>> fileStream 
>> 
>> ifNil: [ Transcript show: 'Fail to create writeStream'; cr ]
>> 
>> ifNotNil: [ Transcript show: 'Opened' ].
>> 
>> fileStream nextPutAll: 'Casimiro de Almeida Barreto'.
>> 
>> fileStream close.
>> 
>> fileStream := ((FileSystem root) / fn) readStream.
>> 
>> l := fileStream upToEnd.
>> 
>> Transcript show: l; cr.
>> 
>> ((FileSystem root) / fn) delete.
>> 
>  
> This example creates a file named 
> c:\temp\380cafd3-c80a-0d00-b117-0a8a049bf78d.txt and I was able to write 
> ‘Casimiro de Almeida Barreto’ to it. And then open the file in the read mode 
> and read ‘Casimiro de Almeida Barreto’ from it. But… ((FileSystem root) / fn) 
> delete returns a: ‘FileDoesNotExist: Path 
> /’temp\380cafd3-c80a-0d00-b117-0a8a049bf78d.txt’. Apparently the problem is 
> at WindowsStore(DiskStore) delete:
>  
> <image001.jpg>
> 
>       Livre de vírus. www.avast.com. 


Reply via email to