Author: Gérard LOCHON
Posted: 2016-08-01 at 05:48:26
This solution must be corrected, because the path length may exceed the
field size limit while recursing thru the directories.
Personnaly, i create another cursor to contains the pathnames :
Pathes(pkid i, path m)
When you start a new subdirectory, you insert it in Pathes cursor, and
in each row of Files cursor you put the Pathes.pkid instead of the path.
A simple request can join the pertinent data.
So far so good, it runs faster and takes less working storage.
Gérard.
Le 01/08/2016 à 10:53, Dave Crozier a écrit :
> Try this 100% VFP solution. It puts the recursive contents of a folder into a cursor with file size and you can then sum the size.
>
> *****************
> * START OF CODE
> *****************
> * Display Files in a Folder within a Table
> * Written by: Dave Crozier
> * Amendments:
> * 04/09/2015 - Add in field to contain file size for Paul Newton
> *
> Clear All
>
> Clear
>
> Public oForm
>
> oForm=Createobject("MyForm",Addbs(Getdir("c:\temp\")),"*.*",.F.)
>
> Define Class MyForm As Form
> AllowOutput=.F. && so '?' output goes to screen
> Width=_Screen.Width
> Height=_Screen.Height-50
> Width=1024
> Height=798
>
> Procedure Init(cPath As String, cMask As String, fSubDir As Boolean)
> Set Exclusive Off
> Set Safety Off
> Set Talk Off
> Set Exact Off
> Create Cursor Files (Path c(240),fname c(240),Fsize N(10,0),Timestamp T)
>
> This.DoDir(cPath,cMask)
>
> Index On Timestamp Descending Tag T && choose your desired order
>
> * INDEX on fsize DESCENDING TAG fsize
>
> With This
> .AddObject("gr","grid")
> With .gr
> .AllowCellSelection=.F.
> .Visible=1
> .Height=Thisform.Height
> .Width = Thisform.Width
> .AutoFit
> .Column3.InputMask="999,999,999"
> Endwith
>
> .Show
> *
> Endwith
>
> Procedure DoDir(cPath As String, cMask As String)
>
> Local N,i,aa[1]
>
> N=Adir(aa,cPath+cMask,"",1)
>
> For i = 1 To N
>
> Insert Into Files (Path,fname,Fsize,Timestamp) Values ;
> (cPath, aa[i,1], aa[i,2], Ctot(Dtoc(aa[i,3])+aa[i,4]))
>
> Endfor
>
> N=Adir(aa,cPath+"*.*","HD",1) && now without the mask, search for directories
>
> For i = 1 To N
>
> If "D"$aa[i,5] && if it's a dir
>
> If aa[i,1] != '.'
>
> This.DoDir(cPath+aa[i,1]+"\",cMask) && recur
>
> Endif
>
> Endif
>
> Endfor
>
> Enddefine
> *
> ****************
> * End of Code
> ****************
>
> Dave
>
>
> -----Original Message-----
> From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Laurie Alvey
> Sent: 31 July 2016 11:22
> To: ProFox Email List <profox@leafe.com>
> Subject: Re: API to find the size of an entire folder structure?
>
> Another useful tool is vfp2c32.fll from VFPx. It has lots of file/folder functions e.g. ADirInfo().
>
> Laurie
>
> On 31 July 2016 at 06:29, Edward Leafe <ed@leafe.com> wrote:
>
>> On Jul 30, 2016, at 8:43 AM, Joe Yoder <joe@wheypower.com> wrote:
>>
>>> Thanks - I suspected that.
>> This is one area where I suspect Linux has an advantage. Looks at all
>> the different ways to approach it:
>> http://www.codecoffee.com/tipsforlinux/articles/22.html
>>
>>
>> -- Ed Leafe
>>
>>
>>
>>
>>
>>
>>
>> --- StripMime Report -- processed MIME parts --- multipart/signed
>> text/plain (text body -- kept)
>> application/pgp-signature
>> ---
>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/91fb345e-a67f-3b0c-e53e-5d2f08ae3c5a@wanadoo.fr
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.