Can you open a bug entry with clear examples? We should improve this part. After having the interpretation of strings sucks. I do not like it I prefer
FileLocator C / 'temp' / 'e8720bb4-b90a-0d00-9b1f-008709e5552b.txt' On Sun, Apr 30, 2017 at 6:54 PM, Casimiro de Almeida Barreto < [email protected]> wrote: > Hello, > > -----Mensagem original----- > De: Pharo-dev [mailto:[email protected]] Em nome de Sven > Van Caekenberghe > Enviada em: domingo, 30 de abril de 2017 05:30 > Para: Pharo Development List <[email protected]> > Assunto: Re: [Pharo-dev] Problem with FileSystem in WIndows > > > > On 30 Apr 2017, at 09:48, Max Leske <[email protected]> wrote: > > > > Hi Casimiro, > > > > have you tried using normal slashes in the path name? FileSystem should > convert those to system path delimiters automatically. So: > > It seems that FileSystem does not convert / into \ . > ((FileSystem root) / 'c:\temp\tempfile.txt') writeStream won´t work but... > FileStream fileNamed: 'C:\temp\tempfile.txt' works ok. > > So... I could make it work for getting a stream both for Unix and Windows: > > OSPlatform currentPlatformName = 'unix' > ifTrue: [ > [ str := (fs / fn) writeStream ] on: Exception do: [ ^ nil > ] ] > ifFalse: [ > [ str := FileStream fileNamed: fn ] on: Exception do: [ ^ > nil ] ]. > > And to delete: > > OSPlatform currentPlatformName = 'unix' > ifTrue: [ > (FileSystem root / aFileName) delete ] > ifFalse: [ > rgx := RxMatcher forString: '^[A-Z]\:'. > drive := rgx matchesIn: aFileName. > drive := (drive at: 1) copyWithRegex: '\:' > matchesReplacedWith: ''. > ((FileLocator driveNamed: drive) / (aFileName > copyWithRegex: '^[A-Z]\:' matchesReplacedWith: '')) delete ] > > Not good, nor elegant nor anything close to good transparent code but... > works :'( > > > > > C:/temp/e8720bb4-b90a-0d00-9b1f-008709e5552b.txt > > > > And possibly you'll need a leading slash, as "C:" is a reference to the > root of the file system: > > > > /C:/temp/e8720bb4-b90a-0d00-9b1f-008709e5552b.txt > > There is also the following option: > > FileLocator C / 'temp' / 'e8720bb4-b90a-0d00-9b1f- > 008709e5552b.txt' > > > Cheers, > > Max > > > >> On 30 Apr 2017, at 03:15, Casimiro de Almeida Barreto < > [email protected]> wrote: > >> > >> Good night all. > >> > >> I´ve had trouble in windows concerning FileSystem. > >> > >> ((FileSystem disk root) / > >> ‘C:\temp\e8720bb4-b90a-0d00-9b1f-008709e5552b.txt’) > delete > >> > >> Fails as if the file didn´t exist. Message: > >> > >> FileDoesNotExist: Path / ‘C:\temp\e8720bb4-b90a-0d00- > 9b1f-008709e5552b.txt’ > >> > >> And I wonder what´s wrong. Because it works in linux and MacOS. > >> > >> Trasncript show: ((FileSYstem disk root) / ‘C:\temp\e8720bb4-b90a-0d00- > 9b1f-008709e5552b.txt’) > >> > >> Returns: > >> > >> File @ C:\temp\e8720bb4-b90a-0d00-9b1f-008709e5552b.txt\ > >> > >> And I wonder where the last \ came from and if is it that is messing > all and how to fix things. > >> > >> Best regards, > >> > >> Casimiro Barreto > >> > >> Livre de vírus. www.avast.com. > > > > > > > --- > Este email foi escaneado pelo Avast antivírus. > https://www.avast.com/antivirus > > >
