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 09:53:58 PDT 2017
On Sunday, 10 September 2017 at 15:46:46 UTC, Ali Çehreli wrote:
> On 09/10/2017 04:54 AM, Vino.B wrote:
>
> > Thank you very much, as stated by you i used the auto
> function and now
> > i am get the output without any warnings
>
> That's because now you're taking advantage of D's type
> inference. Although it doesn't cover the entire story, you may
> want to read about D's Voldemort types. (Your case did not
> involve Voldemort types though; in your case it was just a
> private symbol.)
>
> So, you can give a name to that return value yourself:
>
> alias DirSizeList = typeof(coSizeDirList());
>
> > Sub Function:
>
> Unrelated: They are all called "functions" in D.
>
> > //Array!string MStext;
> > string[][] MStext; // Getting Error on this line, while
> trying to
> > change it to auto;
> > auto MSresult = taskPool.workerLocalStorage(MStext);
>
> Now you can use DirSizeList there:
>
> auto MSresult = taskPool.workerLocalStorage!DirSizeList();
>
> Ali
Hi Ali,
I tried to add/replace the above line's but still not working.
Error: function T2.coSizeDirList (string FFs, int SizeDir) is not
callable using argument types ()
import core.stdc.stdlib: exit;
import std.algorithm: all, among, filter, map, setDifference,
sort, uniq, each, joiner;
import std.array: appender, join;
import std.container.array;
import std.conv: to;
import std.datetime.systime: Clock, days, SysTime;
import std.file: SpanMode, dirEntries, exists, isFile, mkdir,
remove, rmdirRecurse;
import std.getopt;
import std.parallelism: parallel, task, taskPool;
import std.path: absolutePath, baseName, dirName,
isValidFilename, isValidPath, globMatch;
import std.range: empty;
import std.stdio: File, writefln, writeln;
import std.string: chomp, chop, isNumeric, split, strip;
import std.typecons: tuple, Tuple;
import std.uni: isAlpha, toLower, isWhite;
auto coSizeDirList (string FFs, int SizeDir) {
ulong subdirTotal;
ulong subdirTotalGB;
Array!string Subdir;
Array!ulong Subsize;
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[]);
// alias DirSizeList = typeof(coSizeDirList());
}
//alias DirSizeList = typeof(coSizeDirList());
void ptSizeDirList (string[] SizeDirlst, int SizeDir) {
try {
//alias DirSizeList = typeof(coSizeDirList());
auto MSresult = taskPool.workerLocalStorage!DirSizeList();
writeln("Function \t : List the Folder whose Size greater then
", SizeDir, " GB");
writeln("Dir. Scanned \t :", SizeDirlst);
writeln("************************************************************************************");
writefln("%-63s %.20s", "File Name", "Size (GB)");
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 = 10;
coSizeDirList(SizeDirlst, SizeDir);
}
More information about the Digitalmars-d-learn
mailing list