Directory Size
Vino
vino.bheeman at hotmail.com
Thu Dec 7 09:04:19 UTC 2017
On Wednesday, 6 December 2017 at 15:04:55 UTC, Andrea Fontana
wrote:
> On Wednesday, 6 December 2017 at 14:49:48 UTC, Vino wrote:
>
>> Hi Andrea,
>>
>> Thank you very much, as your code is pretty good for our
>> scenario, just one request, the above is a part of our main
>> code where we have many such sub code and all of our sub code
>> use the container array(std.container.array) rather than
>> standard array(std.array), so can you please guide me on how
>> to implement the same code using the container array.
>>
>> From,
>> Vino.B.
>
> Just use Array! constructor.
>
> auto mSize () {
> string FFs = "/home/andrea/Scaricati";
>
> return
> Array!(Tuple!(string,string))(
> dirEntries(FFs, SpanMode.shallow)
> .filter!(a => a.isDir)
> .map!(a => tuple(a.name,
> a.dirEntries(SpanMode.depth).filter!(a=>a.isFile).map!(a =>
> a.size).sum))
> .filter!(a => a[1] > 1024*1024*30)
> .map!(a => tuple(a[0], a[1].to!string))
> );
> }
Hi Andrea,
I test your code, initially it error ed out stating "patch does
not exist", the reason for this error is that the length of the
path is more than 256 , so added the UNC path to the code as
below.
auto mSize () {
string FFs = "C:\Temp\BACKUP";
ulong SGb = 1024 * 1024;
int SizeDir = 10;
return Array!(Tuple!(string,real))(
dirEntries(join(["\\\\?\\", FFs]), SpanMode.shallow).filter!(a
=> a.isDir)
.map!(a => tuple(a.name,
a.dirEntries(SpanMode.depth).filter!(a=>a.isFile)
.map!(a => a.size).sum)).filter!(a => a[1] > (SGb * SizeDir))
.map!(a => tuple(a[0], ((a[1].to!real)/ SGb ))));
}
The output of the code is as below
\\?\C:\Temp\BACKUP\dir1 34.90
\\?\C:\Temp\BACKUP\dir2 36.18
So how do we print the output without UNC path
C:\Temp\BACKUP\dir1 34.90
C:\Temp\BACKUP\dir2 36.18
From,
Vino.B
More information about the Digitalmars-d-learn
mailing list