hi Colin
Is there a way not to have to specify the FileSystem to create a stream for a file on disk? str := FSUnixFilesystem new writeStreamOn: 'giffle'. str nextPutAll: 'zzzzzzzzzz'. str close -> str := 'giffle' asWriteStream str nextPutAll: 'zzzzzzzzzz'. str close is there a way to do currentFolder doWithAllFiles: [:each | Transcript show: each name ; show: each size ; cr] Do I have to use an FSPreOrderGuide? Are there some behavior like doWithAllFiles already defined? I have the impression that having some extensions could make the interfaces smoother. I liked some of the aspects of the rio ones, even if I did not like the chaining one. Stef _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
> hi Colin
I guess he missed that, so let me answer. > Is there a way not to have to specify the FileSystem to create a stream for a file on disk? > > str := FSUnixFilesystem new writeStreamOn: 'giffle'. > str nextPutAll: 'zzzzzzzzzz'. > str close > > -> > > str := 'giffle' asWriteStream > str nextPutAll: 'zzzzzzzzzz'. > str close First of all you should not hardcode the unix platform. Instead let the system resolve the platform for you: (FSDiskFilesystem current / 'griffle') writeStream At the moment there is no shortcut for this on String. I think it would make sense to add a method #asFilesystemReference that would try to guess the right filesystem and answer a reference. So then one could write: 'griffle' asFilesystemReference writeStream 'http://www.lukas-renggli.ch' asFilesystemReference readStream ... > currentFolder doWithAllFiles: [:each | Transcript show: each name ; show: each size ; cr] currentFolder allChildren do: [ :each | > Do I have to use an FSPreOrderGuide? > Are there some behavior like doWithAllFiles already defined? Yes, in the enumeration protocol of FSReference. There are only a few algorithms there, but that will probably grow over time. The FSPreOrderGuide is an internal implementation artifact, it should not be used directly. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
2010/2/14 Lukas Renggli <[hidden email]>:
>> hi Colin > > I guess he missed that, so let me answer. > >> Is there a way not to have to specify the FileSystem to create a stream for a file on disk? >> >> str := FSUnixFilesystem new writeStreamOn: 'giffle'. >> str nextPutAll: 'zzzzzzzzzz'. >> str close >> >> -> >> >> str := 'giffle' asWriteStream >> str nextPutAll: 'zzzzzzzzzz'. >> str close > > First of all you should not hardcode the unix platform. Instead let > the system resolve the platform for you: > > (FSDiskFilesystem current / 'griffle') writeStream > > At the moment there is no shortcut for this on String. I think it > would make sense to add a method #asFilesystemReference that would try > to guess the right filesystem and answer a reference. So then one > could write: > > 'griffle' asFilesystemReference writeStream > 'http://www.lukas-renggli.ch' asFilesystemReference readStream > ... > Do we really reference the file-system or just a file ? asFileReference or asFilename (VW) would be just fine to my own taste. Nicolas >> currentFolder doWithAllFiles: [:each | Transcript show: each name ; show: each size ; cr] > > currentFolder allChildren do: [ :each | > >> Do I have to use an FSPreOrderGuide? >> Are there some behavior like doWithAllFiles already defined? > > Yes, in the enumeration protocol of FSReference. There are only a few > algorithms there, but that will probably grow over time. The > FSPreOrderGuide is an internal implementation artifact, it should not > be used directly. > > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
> Do we really reference the file-system or just a file ?
> > asFileReference or asFilename (VW) would be just fine to my own taste. It can be a directory or filename. It does not have to exist (yet). I agree that the name is long and that there are probably better ones. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
> First of all you should not hardcode the unix platform. Instead let
> the system resolve the platform for you: > > (FSDiskFilesystem current / 'griffle') writeStream I prefer that. I was not happy with my code. > At the moment there is no shortcut for this on String. I think it > would make sense to add a method #asFilesystemReference that would try > to guess the right filesystem and answer a reference. So then one > could write: > > 'griffle' asFilesystemReference writeStream > 'http://www.lukas-renggli.ch' asFilesystemReference readStream > ... > >> currentFolder doWithAllFiles: [:each | Transcript show: each name ; show: each size ; cr] > > currentFolder allChildren do: [ :each | FSDiskFilesystem current workingDirectory allChildren do not work :( I do not understand why workingDirectory return a path and not a reference because this is not workingDirectoryPath So how can I get all the files in my current direct directory FSDiskFilesystem current childrenAt: FSDiskFilesystem current workingDirectory looks ugly >> Do I have to use an FSPreOrderGuide? >> Are there some behavior like doWithAllFiles already defined? > > Yes, in the enumeration protocol of FSReference. There are only a few > algorithms there, but that will probably grow over time. The > FSPreOrderGuide is an internal implementation artifact, it should not > be used directly. > > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |