File Walker
JB
sundown at pacifier.com
Tue Sep 30 13:14:41 EDT 2014
Okay I changed it. When I checked my documents
folder it showed the message box and took a long
time but finally put something in it. The message
looked like some question marks and other stuff
and maybe even some file names.
When I checked my applications folder which I know
has more than 400,000 files it got stuck in a loop and
I finally forced quit the program.
For now I will not use recursive to list files or folders. I
don’t need this to happen to people who use my program
even if they have files that are named wrong since they
are used to Apple finder listing it. They want things like
reading the directory to be consistent. We should not
see any problems with listing the directory unless they
also see it with the finder.
John Balgenorth
On Sep 30, 2014, at 7:43 AM, Alex Tweedly <alex at tweedly.net> wrote:
>
> OK, that really does sound like you are encountering a problem with the combination of the code and your file system - not an inherent limit.
>
> "File Lister 2" should only recurse as deeply as your file system (i.e. it enters a recursion for each level of subfolder - but then exits it again), so to see a "recursion limit" error suggests that it is failing, rather than hitting an actual limit.
>
> Following is a wild guess, and a request / suggestion for an investigation attempt.
>
> The start of the code in question (from http://lessons.runrev.com/m/4071/l/17080-files-and-folders-part-2 ) is
>
> *function*listFiles pFolder, pRecurse
> * local*tTotalFiles, tCurrentFiles, tFolders
>
> * set*thedefaultFoldertopFolder
> * put*filteredFiles()intotCurrentFiles
>
> Now that is risky code !!
> If the "set the defaultfolder to pFolder" fails, then you remain in the same directory, and redo the same work, and get stuck in infinite recursion. This could (maybe??) happen because of permission failures, or maybe folder naming issues, or something else I haven't thought of :-)
>
> So I would change it by adding as follows
> set the defaultfolder to pFolder
> if the defaultfolder <> pFolder then
> put "Failure :" && the defaultfolder && "::" && pFolder &CR after msg
> exit listFiles
> end if
> ...
>
> and see what that does.
>
> Thanks
> -- Alex.**
>
> On 30/09/2014 00:47, JB wrote:
>> That is a good question. The way I found out it was limited is
>> I was using the code supplied in the File Lister 2 tutorial. I was
>> accessing a folder with a lot of files and subfolders but I do not
>> think it had 400,000 files and sub folders in it so I am thinking it
>> is limited to 400,000 recursive attempts. What happened is the
>> script quit while trying to access the files and sub folders and a
>> dialog appeared and said recursive is limited to 400,000. That
>> is worse than being limited to 400,000 files and folders.
>>
>> I think we need to have the NSFIleManager.
>>
>> I have Xcode examples and I was going to try to write an extension
>> since Trevor provided the link for Objective-C externals but I have
>> Mavericks and the latest version of Xcode. I also have xcide 2.4 on
>> this computer and it runs but when I try to compile using the code
>> from Trevor it says something about I can’t use it with this version
>> of OS X or whatever I do not remember, any way it makes me think
>> I need to set up my old system to compile unless someone knows
>> how to make it work with the latest Xcode and then I will probably
>> need all of the older SDK software too. Since I really am not very
>> familiar with any of the above yet I am working on other parts of
>> my program but I will eventually work on putting it all together.
>>
>> With the NSFIleManager I would think we would be able to access
>> directories as fast as Apple since they wrote the code. It looks like
>> it will be pretty easy once I figure a few thing out and write a couple
>> of sample externals with Objective-C. There is not much to using
>> the NSFileManager itself from what I have seen.
>>
>> John Balgenorth
>> On Sep 29, 2014, at 4:10 PM, Alex Tweedly <alex at tweedly.net> wrote:
>>
>>> "recursive is limited to 400,000" ? Is that 400,000 files, or folders, or ??
>>>
>>> The File Walker link (i.e. http://www.sonsothunder.com/devres/livecode/tips/file007.htm ) should work - it would be very interesting to find out why it doesn't (maybe URL encoding of the file names??)
>>>
>>> However, it too is recursive. Here's a non-recursive version of it, which is somewhat faster in some cases: (be careful testing this - you need to run it repeatedly to avoid file-system caching effects).
>>>
>>>
>>> on dirWalk whatFolder
>>> local temp, tCount, tDirList, tDirsToDo
>>> set the itemDel to "/"
>>> set the directory to whatFolder
>>> put whatfolder &CR into tDirsToDo
>>> repeat forever
>>> put line 1 of tDirsToDo into whatFolder
>>> set the directory to whatFolder
>>> delete line 1 of tDirsToDo
>>> put the files into temp
>>> add the number of lines of temp to tCount
>>> sort temp
>>> repeat for each line x in temp
>>> put whatFolder & "/" & x & cr after gHierList
>>> end repeat
>>> put the folders into tDirList
>>> sort tDirList
>>> delete line 1 of tDirList
>>> repeat for each line x in tDirList
>>> put whatFolder & "/" & x & CR after tDirsToDo
>>> end repeat
>>> if the number of lines in tDirsToDo = 0 then exit repeat
>>> end repeat
>>> end dirWalk
>>>
>>> -- Alex.
>>>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list