Indigo Rose Software

Professional Software Development Tools

 
Page 2 of 2 FirstFirst 1 2
Results 16 to 27 of 27
  1. #16
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Here's an updated DLL that lets you choose whether you want to recurse the sub-folders or not.

    BTW, Tig, You're rockin on the script
    Attached Files

  2. #17
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Tig, assuming you're not using the filesall table somewhere else...you can eliminate one more line:

    Code:
    folder = Dialog.FolderBrowse("Please Select a Folder to get its current size", _DesktopFolder);
    StatusDlg.Show(MB_ICONNONE, false);
    if (folder ~= nil) and (folder ~= "CANCEL") then
    	filesall = {};
    	files = File.Find(folder, "*", true, true, nil);
    	fsize = 0;
    	for i,d in files do
    		size = File.GetSize(files[i]);
    		fsize = fsize + size;
    	end
    	fsize = Math.Floor(fsize/1024000);
    	Paragraph.SetText("Paragraph1", "Your directory " .. folder .. " is " .. fsize .. " MB in size.");
    	StatusDlg.Hide();
    end

  3. #18
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Yes you are correct. I was using it but removed those lines. Still trying to learn the ins and outs.

    I added a question that asks if you want to recurse the subdirectories.
    Code:
    folder = Dialog.FolderBrowse("Please Select a Folder to get its current size", _DesktopFolder);
    StatusDlg.Show(MB_ICONNONE, false);
    if (folder ~= nil) and (folder ~= "CANCEL") then
    	recurseq = Dialog.Message("Recurse?", "Would you like to recurse the selected directory?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1);
    	if (recurseq == IDYES) then
    	recurse = true;
    	else
    	recurse = false;
    	end
    	files = File.Find(folder, "*", recurse, true, nil);
    	fsize = 0;
    	for i,d in files do
    		size = File.GetSize(files[i]);
    		fsize = fsize + size;
    	end
    	fsize = Math.Floor(fsize/1024000);
    	Paragraph.SetText("Paragraph1", "Your directory " .. folder .. " is " .. fsize .. " MB in size.");
    	StatusDlg.Hide();
    end
    Last edited by TJ_Tigger; 12-05-2003 at 09:55 AM.

  4. #19
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    size = File.GetSize(files[i]);
    fsize = fsize + size;

    ..to..

    fsize = fsize + File.GetSize(files[i]);


    Removes one less calculation.

    Just notice a little thing in the help file though, if the GetSize fails it will return -1. So in either instance, if the call fails for some reason, we are subtracting from the fsize.
    Last edited by Worm; 12-05-2003 at 10:18 AM.

  5. #20
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Too bad the Callback Functions parameter wasn't the name of the Path and filename, then you could use the callback function to do the GetSize and eliminate the For Loop all together. Maybe there is a way to get the Filename in the callback, but I don't see it. Right now, it sends the folder path.

    Brett? Lorne? Is that possible?

  6. #21
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I like the ability to combine actions into one line of code. I try to do that whenever I can think about it.

  7. #22
    SUF6NEWBIE Guest
    hey guys...

    fsize = Math.Floor(fsize/1024000);

    should be:

    fsize = Math.Floor(fsize/1048000); --bytes to megabytes

    ..do a 'real world' check on a file greater than 1 meg..select properties

    ..have a look at bytes vs meg..(try /1024000 vs 1048000) result ?

    ..if I'm wrong then my system is lying to me..he he

    ..unless math.floor based on total size etc returns different

    ..confirm someone plse

    BTW learning how to keep robust code to a minimum is great !
    Last edited by SUF6NEWBIE; 07-01-2004 at 12:04 AM.

  8. #23
    SUF6NEWBIE Guest
    I've fiddled with the code for Worms Foldersize .dll
    and came up with this 'generic modification' to code offerings
    (I found the dll was not reliable at my end for very large folder trees
    with recurse set to 1. So hence below stuff. Lemme know if can improve !)

    Code:
    --Globals Funcs -wack these in Global functions in AMS5Pro or SUF7.0 or TUv2(beta):
    
    --QNQ
    --GETALL_SIZE_Dll
    
    
    --SOGETALL_SIZE_Dll
    function QNQ(sIn)
    	return "\""..sIn.."\"";
    end
    
    function GETALL_SIZE_Dll()
    --QNQ (Quote/End Quote) global func that encloses 'folder variable' in Quotation Markes for Foldersize.DLL
    --set the recurse option(done elsewhere as below in 'Generic code');
    
    --(Note my testing so far revealed that worms dll only seems work reliably for very large
    --Folder trees or 'sizes', if 'recurse' is set to 0(off) and then cycle through a folder.find table)
    
    	--nRecurse=1;		
    	--nRecurse=0;
    
    FSZ_bts = DLL.CallFunction(_SourceFolder.."\\AutoPlay\\Docs\\Foldersize.DLL", "GetFolderSize", QNQ(sFolder)..","..nRecurse, DLL_RETURN_TYPE_LONG, DLL_RETURN_TYPE_LONG);
    return FSZ_bts;	
    end
    --EOGETALL_SIZE_Dll
    
    
    --some 'Generic' Code to use above Globals -could change to a function if wish to...
    
    	--for example purposes target the Os windows folder	
    	sSrce = _WindowsFolder; --for a 'browse folder' table(change code to suit)
    
    	local tbAll_folders = Folder.Find(sSrce, "*", true, nil);
    	--local tbAll_files = File.Find(sSrce, "*.*", true, false, nil, nil);
    
    	sFolder = sSrce; --for worms foldersize.dll
    	TotalOsfsize = 0;
    	--get root folder first 'sSrce' (covers if contains any binaries !)
    	nRecurse=0; --for worms foldersize.dll
    	GETALL_SIZE_Dll(); --call worms dll
    	Totalfsize = FSZ_bts + Totalfsize; --root folder size done
    
    	--now if desired -cycle through Root folder 'sub tree
    	for nfld, tgtFolder in tbAll_folders do
    		sFolder = tgtFolder;
    		nRecurse=0;
    		GETALL_SIZE_Dll();
    		Totalfsize = FSZ_bts + Totalfsize;
    	end
    	Totalfsize_bytes = Totalfsize; --(changed to test both conversion methods only)
    
    	Totalfsize = Math.Round(((Totalfsize_bytes /1024) /1024), 1); --meg to 1 decimal place
    	Dialog.Message("Debug Only: Folder tree size", Totalfsize.." MB");
    
    	--or use ADAM's funky 'bytes to meg' alogorithim(/ 1048576);
    	Totalfsize = Math.Round((Totalfsize_bytes / 1048576), 1); --meg to 1 decimal place
    	Dialog.Message("Debug Only: Adams's Funky Folder tree size", Totalfsize.." MB");

  9. #24
    SUF6NEWBIE Guest
    oops..modifyng my own app code-missed this one..

    change the line:

    TotalOsfsize = 0;

    to:

    Totalfsize = 0;

  10. #25
    SUF6NEWBIE Guest
    WORM has very kindly offerred to have another look
    at his 'source code' for this very handy 'free dll',

    so if and when he has the time...may not need some of the
    LUA stuff...

  11. #26
    SUF6NEWBIE Guest
    WORM...

    Spent more time with your DLL ...(recurse = 1)
    ..sure seems like a path-depth 'quirk'

    BTW ..the speed of DLL return-s is fantastic..even when cycling through
    and recalling 100's of times or more...reliable...read a DVD9 source with
    12000 binaries 800 folders.. on a PIV ..correct total bytes in under 10 seconds !!
    (equivelent on ata100 hdisk storage --2 seconds)

    So if ya don't get to it ...cycling through with the latest version and
    recurse=0...achieves reliable results at speed TKS once again
    Last edited by SUF6NEWBIE; 01-29-2005 at 12:08 AM.

  12. #27
    Join Date
    Sep 2009
    Posts
    1
    Quite good directory treeview tool called print directory not a freeware but affortable.

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts