Deprecation: std.container.array.RangeT(A) is not visible from module Size

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 11 01:55:21 PDT 2017


On Sunday, 10 September 2017 at 23:10:20 UTC, Ali Çehreli wrote:
> On 09/10/2017 09:53 AM, Vino.B wrote:
>
> > auto coSizeDirList (string FFs, int SizeDir) {
>
> > //alias DirSizeList = typeof(coSizeDirList());
>
> I worked with a version of coSizeDirList() that did not take 
> any parameters. (Could be from an earlier post of yours.)
>
> In this case, you can must use a compilable expression. Since 
> coSizeDirList above takes a string and int, you can get its 
> return value like this:
>
>   alias DirSizeList = typeof(coSizeDirList(string.init, 
> int.init))
>
> The following can work as well:
>
>   alias DirSizeList = typeof(coSizeDirList("", 42))
>
> However, there are other compilation errors when I do that.
>
> Ali

Hi Ali,

The issue occurs at the line "MSresult.get ~= MSizeDirListData" 
when we try to append data the error message is as below, if we 
change this line to "MSresult.get = MSizeDirListData" then the 
code complies without any issue but the output is empty.

T2.d(41): Error: cannot append type Tuple!(RangeT!(Array!string), 
RangeT!(Array!ulong)) to type Tuple!(RangeT!(Array!string), 
RangeT!(Array!ulong))


Code:

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[]);
}

void ptSizeDirList (string[] SizeDirlst, int SizeDir) {
  alias DirSizeList = typeof(coSizeDirList(string.init, 
ulong.init));
  auto MSresult = taskPool.workerLocalStorage!DirSizeList();
  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;
			MSresult.get = MSizeDirListData;
			}
		foreach(i; MSresult.tupleof)
		//if (!i.empty) { writefln("%(%-(%-63s %)\n%)", i[].sort!((a,b) 
=> a[0] < b[0]).uniq); }
		writeln(i);
	}

void main () {
string SizeDirlst = "C:\\Temp\\TEAM\\BACKUP";
int SizeDir = 1;
coSizeDirList(SizeDirlst, SizeDir);
}

From,
Vino.B


More information about the Digitalmars-d-learn mailing list