[Pharo-users] How to construct a multi-part file reference

Sven Van Caekenberghe sven at stfx.eu
Mon May 9 03:13:03 EDT 2016


> On 08 May 2016, at 16:53, Nicolai Hess <nicolaihess at gmail.com> wrote:
> 
> 
> 
> 2016-05-07 0:33 GMT+02:00 Johan Fabry <jfabry at dcc.uchile.cl>:
> Hi all,
> 
> I have a question about the filesystem that I could not resolve using the documentation. The problem is as follows: I have a file reference that is 2 separate strings that I need to join into one complete file ref but I don’t know how because I don’t know what the platform’s file separator is.
> 
> For example, on a unix-like OS I get ‘/home/jfabry’ as one part and ‘test/code/foo.txt’ as the other part, and I need to construct a FileReference to ‘/home/jfabry/test/code/foo.txt’.On M$ I guess this would be 'C:\users\jfabry' and ‘test\code\foo.txt’, so I need to construct FileReference to  'C:\users\jfabry\test\code\foo.txt’
> 
> And the bingo question is: what do I do if I both strings use different kinds of separators?
> 
> I  think
> 
> ‘/home/jfabry’ asFileReference resolve: ‘test/code/foo.txt’
> 
> works on both platform, with both separators, no?

That seems to be the correct way to use the high level API.

> TIA,
> 
> ---> Save our in-boxes! http://emailcharter.org <---
> 
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
> 
> 
> 





More information about the Pharo-users mailing list