Hi
I would like to write a test to see if children includes files | ref children alpha | filesystem createDirectory: '/alpha'. filesystem createDirectory: '/alpha/beta'. filesystem createDirectory: '/alpha/gamma/'. Now how do I create a file? There is createDirectory but not createFile. I think that there is a lot of work before FS can get into the image..... Stef testChildrenWithFilesAndDirectories "Children of a reference are all the files and directories contained in this reference" "self debug: #testChildrenWithFilesAndDirectories" | ref children alpha | filesystem createDirectory: '/alpha'. filesystem createDirectory: '/alpha/beta'. filesystem createDirectory: '/alpha/gamma/'. filesystem working / '/alpha/gamma/'. alpha := filesystem referenceTo: '/alpha'. alpha / 'zork.text'. self halt. ref := filesystem referenceTo: '/alpha'. children := ref children. self assert: children size = 2. children do: [:child | self assert: child class = FSReference. self assert: (child isChildOf: ref). self assert: (#('beta' 'gamma') includes: child basename)] |
Stef,
There is not much sense in creating a file without also putting something inside. There are various methods that give you a write straeam onto a new file. Also note that FSFilesystem>>#createDirectory: is a private method, like about all other methods in there too. You are not supposed to call it directly. Lukas On Friday, 4 February 2011, Stéphane Ducasse <[hidden email]> wrote: > Hi > > I would like to write a test to see if children includes files > > | ref children alpha | > filesystem createDirectory: '/alpha'. > filesystem createDirectory: '/alpha/beta'. > filesystem createDirectory: '/alpha/gamma/'. > > Now how do I create a file? There is createDirectory but not createFile. > > I think that there is a lot of work before FS can get into the image..... > > Stef > > > > > testChildrenWithFilesAndDirectories > "Children of a reference are all the files and directories contained in this reference" > "self debug: #testChildrenWithFilesAndDirectories" > | ref children alpha | > filesystem createDirectory: '/alpha'. > filesystem createDirectory: '/alpha/beta'. > filesystem createDirectory: '/alpha/gamma/'. > filesystem working / '/alpha/gamma/'. > alpha := filesystem referenceTo: '/alpha'. > alpha / 'zork.text'. > self halt. > ref := filesystem referenceTo: '/alpha'. > children := ref children. > self assert: children size = 2. > > children do: > [:child | > self assert: child class = FSReference. > self assert: (child isChildOf: ref). > self assert: (#('beta' 'gamma') includes: child basename)] > -- Lukas Renggli www.lukas-renggli.ch |
On Feb 4, 2011, at 5:10 PM, Lukas Renggli wrote: > Stef, > > There is not much sense in creating a file without also putting > something inside. There are various methods that give you a write > straeam onto a new file. yes but consistent never hurts. And I could create en empty file because an empty is an information. Do you know how to rename a file? Because I could not figure out. > Also note that FSFilesystem>>#createDirectory: is a private method, > like about all other methods in there too. You are not supposed to > call it directly. Now I hate FS. I will stop working on it. I prefer a worse system with doc that one better without. I'm spending hours on it and I'm crawling just because colin never ever thought that one idiot could want to use it. I cannot work on something that aliens me that way, too bad. Tx for your answer for me this is the end of the story. Wonderful community that does not know how to write comments. We can always cry that the world does not recognize Smalltalk value, but when I see python docs, they got it right! Stef |
In reply to this post by Lukas Renggli
I've written tests with empty files like so:
(aReference / 'emptyFile) writeStreamDo: [ :stream | ]. It's a bit lengthy but it's a pretty cool syntax for most write operations to files. Max On 04.02.2011, at 17:10, Lukas Renggli wrote: > Stef, > > There is not much sense in creating a file without also putting > something inside. There are various methods that give you a write > straeam onto a new file. > > Also note that FSFilesystem>>#createDirectory: is a private method, > like about all other methods in there too. You are not supposed to > call it directly. > > Lukas > > On Friday, 4 February 2011, Stéphane Ducasse <[hidden email]> wrote: >> Hi >> >> I would like to write a test to see if children includes files >> >> | ref children alpha | >> filesystem createDirectory: '/alpha'. >> filesystem createDirectory: '/alpha/beta'. >> filesystem createDirectory: '/alpha/gamma/'. >> >> Now how do I create a file? There is createDirectory but not createFile. >> >> I think that there is a lot of work before FS can get into the image..... >> >> Stef >> >> >> >> >> testChildrenWithFilesAndDirectories >> "Children of a reference are all the files and directories contained in this reference" >> "self debug: #testChildrenWithFilesAndDirectories" >> | ref children alpha | >> filesystem createDirectory: '/alpha'. >> filesystem createDirectory: '/alpha/beta'. >> filesystem createDirectory: '/alpha/gamma/'. >> filesystem working / '/alpha/gamma/'. >> alpha := filesystem referenceTo: '/alpha'. >> alpha / 'zork.text'. >> self halt. >> ref := filesystem referenceTo: '/alpha'. >> children := ref children. >> self assert: children size = 2. >> >> children do: >> [:child | >> self assert: child class = FSReference. >> self assert: (child isChildOf: ref). >> self assert: (#('beta' 'gamma') includes: child basename)] >> > > -- > Lukas Renggli > www.lukas-renggli.ch > |
In reply to this post by Stéphane Ducasse
There is no native rename. It's pretty much read the contents, delete the file, create a new file from contents.
Max On 04.02.2011, at 17:31, Stéphane Ducasse wrote: > > On Feb 4, 2011, at 5:10 PM, Lukas Renggli wrote: > >> Stef, >> >> There is not much sense in creating a file without also putting >> something inside. There are various methods that give you a write >> straeam onto a new file. > > yes but consistent never hurts. > And I could create en empty file because an empty is an information. > > Do you know how to rename a file? Because I could not figure out. > >> Also note that FSFilesystem>>#createDirectory: is a private method, >> like about all other methods in there too. You are not supposed to >> call it directly. > > > Now I hate FS. I will stop working on it. > I prefer a worse system with doc that one better without. I'm spending hours on it and I'm crawling > just because colin never ever thought that one idiot could want to use it. > > I cannot work on something that aliens me that way, too bad. > > Tx for your answer for me this is the end of the story. Wonderful community that does not know how to write comments. > > We can always cry that the world does not recognize Smalltalk value, but when I see python docs, they got it right! > > Stef |
Free forum by Nabble | Edit this page |