Deprecation: std.container.array.RangeT(A) is not visible from module Size
Vino.B via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 10 04:54:17 PDT 2017
On Friday, 8 September 2017 at 23:48:14 UTC, Ali Çehreli wrote:
> On 09/08/2017 11:21 AM, Vino.B wrote:
>
> > One final help on how to print the below
> > output , just in case if this issue is fixed in next release,
> >
> > Output:
> > [Tuple!string("C:\\Temp\\sapnas2\\BACKUP\\dir1"),
> > Tuple!string("C:\\Temp\\sapnas2\\BACKUP\\DND5")][34, 4]
> >
> > Required output:
> > C:\\Temp\\sapnas2\\BACKUP\\dir1 34
> > C:\\Temp\\sapnas2\\BACKUP\\DND5 4
>
> std.algorithm.zip can help:
>
> void main () {
> auto results = coSizeDirList();
> auto dirs = results[][0]; // A range
> auto sizes = results[][1]; // Another range
> auto combined = zip(dirs, sizes); // Corresponding
> elements linked
>
> foreach (result; combined) {
> auto dir = result[0]; // The element from the first
> range
> auto size = result[1]; // The element from the
> second range
> writefln("%-40s %20s", dir, size);
> }
> }
>
> Ali
Hi Ali,
Thank you very much, as stated by you i used the auto function
and now i am get the output without any warnings, but this do not
help me in my overall program, meaning, when i call this sub
function from the main thread function program it is not working
as expected and throwing an error.
Sub Function:
auto coSizeDirList (string FFs, int SizeDir) {
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[]);
}
Main Thread function :
void ptSizeDirList (string[] SizeDirlst, int SizeDir) {
try {
//Array!string MStext;
string[][] MStext; // Getting Error on this line, while
trying to change it to auto;
auto MSresult = taskPool.workerLocalStorage(MStext);
logF.writeln("Function \t : List the Folder whose Size greater
then ", SizeDir, " GB");
logF.writeln("Dir. Scanned \t :", SizeDirlst);
logF.writeln("************************************************************************************");
logF.writefln("%-63s %.20s", "File Name", "Size (GB)");
logF.writeln("************************************************************************************");
foreach (string Fs; parallel(SizeDirlst[0 .. $], 1)) {
auto FFs = Fs.strip;
auto MSizeDirList = task(&coSizeDirList, FFs, SizeDir);
MSizeDirList.executeInNewThread();
auto MSizeDirListData = MSizeDirList.workForce;
MSresult.get ~= MSizeDirListData;
}
foreach(i; MSresult.toRange)
if (!i.empty) {
writefln("%(%-(%-63s %)\n%)", i[].sort!((a,b) => a[0] <
b[0]).uniq); }
writeln("************************************************************************************");
} catch (Exception e) { writeln(e.msg); }
}
void main () {
string SizeDirlst = "C:\\Temp\\sapnas2\\BACKUP";
int SizeDir = 1;
ptSizeDirList(SizeDirlst, SizeDir);
}
Error:
Error: no identifier for declarator MStext
Deprecation: use { } for an empty statement, not ;
More information about the Digitalmars-d-learn
mailing list