Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 06, 2017 Container Array | ||||
---|---|---|---|---|
| ||||
HI All, Can some one provide me a example of how to use the std.container.array for the below code. import std.algorithm: filter, map; import std.file: SpanMode, dirEntries, isDir; import std.stdio: writeln; import std.typecons: tuple; import std.array: array; void main () { string[] Filesys = ["C:\\Temp\\TEST1\\BACKUP", "C:\\Temp\\TEST2\\EXPORT"]; foreach(FFs; Filesys) { auto dFiles = dirEntries("C:\\Temp\\TEST1\\BACKUP", SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, a.size)); foreach(d; dFiles) writeln(d[0], "\t", d[1]); } } From, Vino.B |
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On Wednesday, 6 September 2017 at 16:41:06 UTC, Vino.B wrote: > HI All, > > Can some one provide me a example of how to use the std.container.array for the below code. > > import std.algorithm: filter, map; > import std.file: SpanMode, dirEntries, isDir; > import std.stdio: writeln; > import std.typecons: tuple; > import std.array: array; > > void main () { > string[] Filesys = ["C:\\Temp\\TEST1\\BACKUP", "C:\\Temp\\TEST2\\EXPORT"]; > foreach(FFs; Filesys) { > auto dFiles = dirEntries("C:\\Temp\\TEST1\\BACKUP", SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, a.size)); > foreach(d; dFiles) > writeln(d[0], "\t", d[1]); > } > } > > From, > Vino.B Hi, I tried a small code using container array, and the output i get form the code is a below, so can one help me on this issue. Program: import std.algorithm: filter, map; import std.file: SpanMode, dirEntries, isDir; import std.stdio: writeln; import std.typecons: tuple, Tuple; import std.container; Array!(Tuple!(string, string)) coCleanFiles() { auto dFiles = make!Array(dirEntries("C:\\Temp\\TEST1\\BACKUP", SpanMode.shallow).filter!(a => a.isFile).map!(a => tuple(a.name, a.timeCreated.toSimpleString[0 .. 20]))); return dFiles; } void main () { writeln(coCleanFiles); } Output: Array!(Tuple!(string, string))(RefCounted!(Payload, cast(RefCountedAutoInitialize)0)(RefCountedStore(62D818))) From, Vino.B |
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On 09/07/2017 03:56 AM, Vino.B wrote:
> writeln(coCleanFiles);
Access the elements by taking a slice of the container:
writeln(coCleanFiles[]);
Ali
|
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Thursday, 7 September 2017 at 14:26:08 UTC, Ali Çehreli wrote:
> On 09/07/2017 03:56 AM, Vino.B wrote:
>
>> writeln(coCleanFiles);
>
> Access the elements by taking a slice of the container:
>
> writeln(coCleanFiles[]);
>
> Ali
Hi Ali,
Thank you very much, was ablee to resolve this issue and now facing a new issue as the below code is not working as expected. The below code has to list the folders and their size's.
import std.algorithm: filter, map, fold;
import std.container;
import std.file: SpanMode, dirEntries, isDir;
import std.stdio: File, writefln, writeln;
import std.typecons: tuple, Tuple;
import std.parallelism: parallel;
Array!(Tuple!(string, ulong)) coSizeDirList () {
string FFs = "C:\\Temp\\TEST1\\BACKUP";
int SizeDir = 10;
ulong subdirTotal;
ulong subdirTotalGB;
auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name)));
foreach (d; dFiles) {
auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size)));
foreach(f; parallel(SdFiles, 1)) { subdirTotal += f.fold!((a, b) => a + b); }
subdirTotalGB = (subdirTotal/1024/1024);
if (subdirTotalGB > SizeDir) { auto Subdata = Array!(Tuple!(string, ulong))(dFiles ~ subdirTotalGB); }
subdirTotal = 0;
}
return Subdata;
}
void main () {
writeln (coSizeDirList[]);
}
|
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On Thursday, 7 September 2017 at 15:07:56 UTC, Vino.B wrote:
> On Thursday, 7 September 2017 at 14:26:08 UTC, Ali Çehreli wrote:
>> On 09/07/2017 03:56 AM, Vino.B wrote:
>>
>>> writeln(coCleanFiles);
>>
>> Access the elements by taking a slice of the container:
>>
>> writeln(coCleanFiles[]);
>>
>> Ali
>
> Hi Ali,
>
> Thank you very much, was ablee to resolve this issue and now facing a new issue as the below code is not working as expected. The below code has to list the folders and their size's.
>
> import std.algorithm: filter, map, fold;
> import std.container;
> import std.file: SpanMode, dirEntries, isDir;
> import std.stdio: File, writefln, writeln;
> import std.typecons: tuple, Tuple;
> import std.parallelism: parallel;
>
> Array!(Tuple!(string, ulong)) coSizeDirList () {
> string FFs = "C:\\Temp\\TEST1\\BACKUP";
> int SizeDir = 10;
> ulong subdirTotal;
> ulong subdirTotalGB;
> auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name)));
> foreach (d; dFiles) {
> auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size)));
> foreach(f; parallel(SdFiles, 1)) { subdirTotal += f.fold!((a, b) => a + b); }
> subdirTotalGB = (subdirTotal/1024/1024);
> if (subdirTotalGB > SizeDir) { auto Subdata = Array!(Tuple!(string, ulong))(dFiles ~ subdirTotalGB); }
> subdirTotal = 0;
> }
> return Subdata;
> }
>
> void main () {
> writeln (coSizeDirList[]);
> }
Hi,
Few updates,
If i change the function to main i am able to print the required output, but if i change the main to function and call this function from another main then i am not able to return the result from the function.
Updated Code:
import std.algorithm: filter, map, fold;
import std.container;
import std.file: SpanMode, dirEntries, isDir;
import std.stdio: File, writefln, writeln;
import std.typecons: tuple, Tuple;
import std.parallelism: parallel;
import std.conv;
Array!(Tuple!(string, ulong)) coSizeDirList () {
//void main () {
string FFs = "C:\\Temp\\sapnas2\\BACKUP";
int SizeDir = 1;
ulong subdirTotal;
ulong subdirTotalGB;
Array!(Tuple!(ulong)) Subdata;
auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name)));
foreach (d; dFiles[]) {
auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size)));
foreach(f; SdFiles[]) { subdirTotal += f.fold!((a, b) => a + b); }
subdirTotalGB = (subdirTotal/1024/1024);
if (subdirTotalGB > SizeDir) { Subdata ~= subdirTotalGB; }
subdirTotal = 0;
}
//writeln(dFiles);
//writeln(Subdata);
return dFiles[];
return Subdata[];
}
void main () {
writeln (coSizeDirList[]);
}
From,
Vino.B
|
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On Thursday, 7 September 2017 at 17:12:14 UTC, Vino.B wrote: > On Thursday, 7 September 2017 at 15:07:56 UTC, Vino.B wrote: >> On Thursday, 7 September 2017 at 14:26:08 UTC, Ali Çehreli wrote: >>> On 09/07/2017 03:56 AM, Vino.B wrote: >>> >>>> writeln(coCleanFiles); >>> >>> Access the elements by taking a slice of the container: >>> >>> writeln(coCleanFiles[]); >>> >>> Ali >> >> Hi Ali, >> >> Thank you very much, was ablee to resolve this issue and now facing a new issue as the below code is not working as expected. The below code has to list the folders and their size's. >> >> import std.algorithm: filter, map, fold; >> import std.container; >> import std.file: SpanMode, dirEntries, isDir; >> import std.stdio: File, writefln, writeln; >> import std.typecons: tuple, Tuple; >> import std.parallelism: parallel; >> >> Array!(Tuple!(string, ulong)) coSizeDirList () { >> string FFs = "C:\\Temp\\TEST1\\BACKUP"; >> int SizeDir = 10; >> ulong subdirTotal; >> ulong subdirTotalGB; >> auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name))); >> foreach (d; dFiles) { >> auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size))); >> foreach(f; parallel(SdFiles, 1)) { subdirTotal += f.fold!((a, b) => a + b); } >> subdirTotalGB = (subdirTotal/1024/1024); >> if (subdirTotalGB > SizeDir) { auto Subdata = Array!(Tuple!(string, ulong))(dFiles ~ subdirTotalGB); } >> subdirTotal = 0; >> } >> return Subdata; >> } >> >> void main () { >> writeln (coSizeDirList[]); >> } > > Hi, > > Few updates, > > If i change the function to main i am able to print the required output, but if i change the main to function and call this function from another main then i am not able to return the result from the function. > > Updated Code: > import std.algorithm: filter, map, fold; > import std.container; > import std.file: SpanMode, dirEntries, isDir; > import std.stdio: File, writefln, writeln; > import std.typecons: tuple, Tuple; > import std.parallelism: parallel; > import std.conv; > Array!(Tuple!(string, ulong)) coSizeDirList () { > //void main () { > string FFs = "C:\\Temp\\sapnas2\\BACKUP"; > int SizeDir = 1; > ulong subdirTotal; > ulong subdirTotalGB; > Array!(Tuple!(ulong)) Subdata; > auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name))); > foreach (d; dFiles[]) { > auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size))); > foreach(f; SdFiles[]) { subdirTotal += f.fold!((a, b) => a + b); } > subdirTotalGB = (subdirTotal/1024/1024); > if (subdirTotalGB > SizeDir) { Subdata ~= subdirTotalGB; } > subdirTotal = 0; > } > //writeln(dFiles); > //writeln(Subdata); > return dFiles[]; > return Subdata[]; > } > > void main () { > writeln (coSizeDirList[]); > } > > From, > Vino.B Few Update: Update Code : import std.algorithm: filter, map, fold; import std.container; import std.file: SpanMode, dirEntries, isDir; import std.stdio: File, writefln, writeln; import std.typecons: tuple, Tuple; import std.parallelism: parallel; import std.conv; Array!(Tuple!(string, ulong)) coSizeDirList () { //void main () { string FFs = "C:\\Temp\\sapnas2\\BACKUP"; int SizeDir = 1; ulong subdirTotal; ulong subdirTotalGB; Array!ulong Subdata; auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name))); foreach (d; dFiles[]) { auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size))); foreach(f; SdFiles[]) { subdirTotal += f.fold!((a, b) => a + b); } subdirTotalGB = (subdirTotal/1024/1024); if (subdirTotalGB > SizeDir) { Subdata ~= subdirTotalGB; } subdirTotal = 0; } //writeln(dFiles[]); //writeln(Subdata[]); return tuple (dFiles[], Subdata[]); //return Subdata[]; //return Result; } void main () { writeln (coSizeDirList[]); } Error Output Test1.d(27): Error: cannot implicitly convert expression (tuple(dFiles.opSlice(), Subdata.opSlice())) of type Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) to Array!(Tuple!(string, ulong)) Failed: ["dmd", "-v", "-o-", "Test1.d", "-I."] From, Vino.B |
September 07, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On 09/07/2017 10:39 AM, Vino.B wrote: > Array!(Tuple!(string, ulong)) coSizeDirList () { You stated the return type explicitly above. > return tuple (dFiles[], Subdata[]); According to the error message, what is being returned does not have the same type: > Test1.d(27): Error: cannot implicitly convert expression > (tuple(dFiles.opSlice(), Subdata.opSlice())) of type > Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) to > Array!(Tuple!(string, ulong)) The actual return type is Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) There needs to be some transformations to match the two. Ali |
September 08, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Thursday, 7 September 2017 at 20:47:43 UTC, Ali Çehreli wrote: > On 09/07/2017 10:39 AM, Vino.B wrote: > > > Array!(Tuple!(string, ulong)) coSizeDirList () { > > You stated the return type explicitly above. > > > return tuple (dFiles[], Subdata[]); > > According to the error message, what is being returned does not have the same type: > > > Test1.d(27): Error: cannot implicitly convert expression > > (tuple(dFiles.opSlice(), Subdata.opSlice())) of type > > Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) to > > Array!(Tuple!(string, ulong)) > > The actual return type is > > Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) > > There needs to be some transformations to match the two. > > Ali Hi Ali, At last was able to print the output, but i am getting some "Deprecation" warnings like below and also can you help me in formating the output to display ulong. Output: Size.d(9): Deprecation: std.container.array.RangeT(A) is not visible from module Size Size.d(9): Deprecation: std.container.array.RangeT(A) is not visible from module Size Size.d(9): Deprecation: std.container.array.RangeT(A) is not visible from module Size Size.d(9): Deprecation: std.container.array.RangeT(A) is not visible from module Size [Tuple!string("C:\\Temp\\sapnas2\\BACKUP\\dir1"), Tuple!string("C:\\Temp\\sapnas2\\BACKUP\\DND3"), Tuple!string("C:\\Temp\\sapnas2\\BACKUP\\DND5")][34, 4] Program: import std.algorithm: filter, map, fold; import std.container; import std.file: SpanMode, dirEntries, isDir; import std.stdio: File, writefln, writeln; import std.typecons: tuple, Tuple; import std.parallelism: parallel; import std.conv; import std.range; Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) coSizeDirList () { string FFs = "C:\\Temp\\sapnas2\\BACKUP"; int SizeDir = 1; ulong subdirTotal; ulong subdirTotalGB; Array!(ulong) Subdata; auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name))); foreach (d; dFiles[]) { auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], SpanMode.depth).map!(a => tuple(a.size))); foreach(f; SdFiles[]) { subdirTotal += f.fold!((a, b) => a + b); } subdirTotalGB = (subdirTotal/1024/1024); if (subdirTotalGB > SizeDir) { Subdata ~= subdirTotalGB; } subdirTotal = 0; } return tuple (dFiles[], Subdata[]); } void main () { writeln(coSizeDirList[]); //writefln("%(%-(%-63s %)\n%)", coSizeDirList[]); } |
September 08, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vino.B | On 09/07/2017 11:21 PM, Vino.B wrote: > At last was able to print the output, but i am getting some > "Deprecation" warnings like below and also can you help me in formating > the output to display ulong. > > Output: > Size.d(9): Deprecation: std.container.array.RangeT(A) is not visible > from module Size That's due to std.container.array.RangeT being private. The deprecation warning is about a bug that leaked such private symbols when they were imported selectively (I think). Now the bug is fixed, you won't be able to access the symbol at the end of the deprecation period. > import std.algorithm: filter, map, fold; > import std.container; > import std.file: SpanMode, dirEntries, isDir; > import std.stdio: File, writefln, writeln; > import std.typecons: tuple, Tuple; > import std.parallelism: parallel; > import std.conv; > import std.range; > Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong)) > coSizeDirList () { > string FFs = "C:\\Temp\\sapnas2\\BACKUP"; > int SizeDir = 1; > ulong subdirTotal; > ulong subdirTotalGB; > Array!(ulong) Subdata; > auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs, > SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name))); > foreach (d; dFiles[]) { > auto SdFiles = Array!(Tuple!(ulong)) (dirEntries(d[0], > SpanMode.depth).map!(a => tuple(a.size))); > foreach(f; SdFiles[]) { subdirTotal += f.fold!((a, b) => > a + b); } > subdirTotalGB = (subdirTotal/1024/1024); > if (subdirTotalGB > SizeDir) { Subdata ~= > subdirTotalGB; } > subdirTotal = 0; > } > return tuple (dFiles[], Subdata[]); > } > > void main () { > writeln(coSizeDirList[]); > //writefln("%(%-(%-63s %)\n%)", coSizeDirList[]); > } I apologize for not really having time to look at what you're trying to achieve. I gave you advice which ended up trying to solve compilation errors. I think the main problem here is to determine directories above a certain size. So, I think Array should enter the picture only if built-in arrays are not usable for some reason. Even better, one should stay with lazy range algorithms as long as it's possible. How about the following approach, which you can either use directly or populate an Array with: import std.algorithm: filter, map, sum; import std.file: SpanMode, dirEntries, isDir, DirEntry; import std.stdio: writeln; auto dFiles(string dirName) { return dirEntries(dirName, SpanMode.shallow).filter!(a => a.isDir); } auto totalSize(DirEntry dir) { return dirEntries(dir, SpanMode.depth).map!(a => a.size).sum; } struct DirInfo { string name; ulong size; } auto coSizeDirList (string dirName, ulong sizeLimit) { return dFiles(dirName).map!(dir => DirInfo(dir.name, dir.totalSize)).filter!(info => info.size > sizeLimit); } void main () { writeln(coSizeDirList("./deleteme", 1)); // Only if Array is really needed: import std.container : Array; auto arr = Array!DirInfo(coSizeDirList("./deleteme", 42)); writeln(arr[]); } Ali |
September 08, 2017 Re: Container Array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 8 September 2017 at 09:51:38 UTC, Ali Çehreli wrote:
> On 09/07/2017 11:21 PM, Vino.B wrote:
>
> > At last was able to print the output, but i am getting some
> > "Deprecation" warnings like below and also can you help me in
> formating
> > the output to display ulong.
> >
> > Output:
> > Size.d(9): Deprecation: std.container.array.RangeT(A) is not
> visible
> > from module Size
>
> That's due to std.container.array.RangeT being private. The deprecation warning is about a bug that leaked such private symbols when they were imported selectively (I think). Now the bug is fixed, you won't be able to access the symbol at the end of the deprecation period.
>
> > import std.algorithm: filter, map, fold;
> > import std.container;
> > import std.file: SpanMode, dirEntries, isDir;
> > import std.stdio: File, writefln, writeln;
> > import std.typecons: tuple, Tuple;
> > import std.parallelism: parallel;
> > import std.conv;
> > import std.range;
> > Tuple!(RangeT!(Array!(Tuple!string)), RangeT!(Array!ulong))
> > coSizeDirList () {
> > string FFs = "C:\\Temp\\sapnas2\\BACKUP";
> > int SizeDir = 1;
> > ulong subdirTotal;
> > ulong subdirTotalGB;
> > Array!(ulong) Subdata;
> > auto dFiles = Array!(Tuple!(string)) (dirEntries(FFs,
> > SpanMode.shallow).filter!(a => a.isDir).map!(a =>
> tuple(a.name)));
> > foreach (d; dFiles[]) {
> > auto SdFiles = Array!(Tuple!(ulong))
> (dirEntries(d[0],
> > SpanMode.depth).map!(a => tuple(a.size)));
> > foreach(f; SdFiles[]) { subdirTotal +=
> f.fold!((a, b) =>
> > a + b); }
> > subdirTotalGB = (subdirTotal/1024/1024);
> > if (subdirTotalGB > SizeDir) { Subdata ~=
> > subdirTotalGB; }
> > subdirTotal = 0;
> > }
> > return tuple (dFiles[], Subdata[]);
> > }
> >
> > void main () {
> > writeln(coSizeDirList[]);
> > //writefln("%(%-(%-63s %)\n%)", coSizeDirList[]);
> > }
>
> I apologize for not really having time to look at what you're trying to achieve. I gave you advice which ended up trying to solve compilation errors.
>
> I think the main problem here is to determine directories above a certain size. So, I think Array should enter the picture only if built-in arrays are not usable for some reason. Even better, one should stay with lazy range algorithms as long as it's possible.
>
> How about the following approach, which you can either use directly or populate an Array with:
>
> import std.algorithm: filter, map, sum;
> import std.file: SpanMode, dirEntries, isDir, DirEntry;
> import std.stdio: writeln;
>
> auto dFiles(string dirName) {
> return dirEntries(dirName, SpanMode.shallow).filter!(a => a.isDir);
> }
>
> auto totalSize(DirEntry dir) {
> return dirEntries(dir, SpanMode.depth).map!(a => a.size).sum;
> }
>
> struct DirInfo {
> string name;
> ulong size;
> }
>
> auto coSizeDirList (string dirName, ulong sizeLimit) {
> return dFiles(dirName).map!(dir => DirInfo(dir.name, dir.totalSize)).filter!(info => info.size > sizeLimit);
> }
>
> void main () {
> writeln(coSizeDirList("./deleteme", 1));
>
> // Only if Array is really needed:
> import std.container : Array;
> auto arr = Array!DirInfo(coSizeDirList("./deleteme", 42));
> writeln(arr[]);
> }
>
> Ali
Hi Ali,
As stated earlier my release 1 code are still using std.array, so now in release 2 i am converting all my standard array to container array. My program has 5 function and I was able to adopt 4 function to container array, and facing issue with this 1 function. I would like to have all my function to be neither in standard array nor in container array, more over I am facing gc issue in standard array and this is the main reason I would like to convert my function to container array, as this function would find the size of folder which are greater then a specified size in a 5 file system each with 10 TB, so i have added the thread(with Local storage) and parallelism to my function as container array give's me the option of reserving memory, so that i would bump it up as and when it is required with any gc issues. All help to resolve this issue would be appreciated.
Updated Code:
import std.algorithm: filter, map, fold;
import std.container;
import std.file: SpanMode, dirEntries, isDir;
import std.stdio: File, writefln, writeln;
import std.typecons: tuple, Tuple;
import std.parallelism: parallel;
import std.conv;
import std.range;
Tuple!(RangeT!(Array!string), RangeT!(Array!ulong)) coSizeDirList () {
string FFs = "C:\\Temp\\sapnas2\\BACKUP";
int SizeDir = 1;
ulong subdirTotal;
ulong subdirTotalGB;
Array!(string) Subdir;
Array!(ulong) Subsize;
Tuple!((Array!string), (Array!string)) Result;
auto dFiles = Array!string ((dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir))[].map!(a => a.name));
foreach (d; dFiles[]) {
auto SdFiles = Array!ulong ((dirEntries(d, SpanMode.depth)).map!(a => a.size));
foreach(f; SdFiles[]) { subdirTotal += f; }
subdirTotalGB = (subdirTotal/1024/1024); { Subdir ~= d; Subsize ~= subdirTotalGB; }
if (subdirTotalGB > SizeDir)
subdirTotal = 0;
}
return tuple (Subdir[], Subsize[]);
}
void main () {
writeln(coSizeDirList[]);
}
From,
Vino.B
|
Copyright © 1999-2021 by the D Language Foundation