Replying to include the beginners list
| recurse |"<—-[ this will make a tree of Objects isomorphic to the directory tree on Disk ]"recurse := [ :directory |XXXDirectoryCard newsubDirectories:(directory subDirectories "<—-[ somehow you get the subDirectories ]"collect: recurse )fileCards:( directory files "<———[ somehow you get the files ]"collect:[ :file |XXXFileCard newauthor:( file author );"<—[ somehow you get the author ]"etc:( file etc ) ;"<————[ etc ]"yourself ] )] value:( myLibraryBase asDirectory )"<——-[ XXX equals your initialslike if your name is John Q Public your initials are JQP this is a simple wayto stop Class name clashes if Card is a popular Class name because therecan only be one Card Class in the system so if multiple people all have aCard Class defined then only the first one to load will be loaded andwhen the rest try to load there will be a fatal Error Class already exists ]"String>>asDirectory ^File directory: self "<——-[ or something ]"[ :recurse | recurse value:( myLibraryBase asDirectory )value: recurse]value:[ :directory :recurse |XXXDirectoryCard newsubDirectories:(directory subDirectories "<—-[ somehow you get the subDirectories ]"collect: recurse )fileCards:( directory files "<———[ somehow you get files ]"collect:[ :file |XXXFileCard newauthor:( file author );"<—[ somehow you get the author ]"etc:( file etc ) ;"<————[ etc ]"yourself )]"<——-[ here is a more functional style if you have func disease ][ like me ][ if your compiler even cares ][ probably it does not ][ who knows who cares not me ]"
On Wed, Oct 25, 2023 at 18:57 <lewis@mail.msen.com> wrote:Hi,
This is a very good question.
I do not have a good answer, but I am replying here with CC to the
squeak-dev list because I would like to get a response to this question.
In my own personal experience, when I want to traverse the files and
directories, I am in the habit of just using the traditional unix 'find'
utility because it does a very good job of this, and it knows how to
handle file system dependencies such as links and symlinks. I can
use the results of the 'find' command in Squeak, so that works well
for me.
But if I want to traverse a file system tree directly in Squeak, is
there a good simple way to do it? Presumably one would want to visit
each node in the tree and evaluate a block to do something. In the
example below, we would want the block to create an instance of
class Card for each file node that is visited.
For folks replying on squeak-dev please keep in mind that the
question originates from the beginners list, so we are looking
for a clear and simple answer :-)
Thanks,
Dave
On 2023-10-24 18:27, ruivianapereira@gmail.com wrote:
> I'm not a programmer of any kind or language; I'm an amateur.
> I have a personal digital library with thousands of documents, which
> are useless unless I manage to classify them.
> I thought it would be an easy task with Squeak, since it is a quite
> simple problem, but I'm lacking some solutions, as a beginner.
> My general cenario:
> I made a class, lets call it card, to hold information about each work,
> each author, their location on disk and the relations between authors
> and works:
> Object>>#Card (instance var : name, location, notes, tags ... ) Author
> Work
Object>>#MyLibrary (instance var : authors <aCollection>, works
<aCollection>, myLibraryBase <aPath?>)
Than I initialize #MyLibrary instances with a UIManager directoryChooser
to establish from the begining a reference to the directory where all
the relevant files are.
But, because it is thousands of files, I would need an automatic method
to «scan» all the relevant files in the directories and subdirectories.
Meaning: the method should make a collection of all the files,
recursively in subdirectories, and for each one it should create a card.
And that's where I got stuck: how do I scan recursively the
subdirectories?
Most of the new tools are quite confusing for me, namely classes and
tools to deal with files.
Can anyone point me in the wright direction, please?
Thanks
_______________________________________________
Beginners mailing list -- beginners@lists.squeakfoundation.org
To unsubscribe send an email to
beginners-leave@lists.squeakfoundation.org