Direntries seems to on other drives. (windows)

Taylor Hillegeist via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 31 19:05:23 PDT 2016


SO i have a maximum scope depth tool, that i just put together it 
is super simple.
but when i use it in a drive other that C:\ i get an error. Even 
though i just checked for a valid path.

Any ideas?

C:\Users\taylor.hillegeist\Documents\CodeSync\D 
projects\Toys\TOOLS>NestCheck.exe 
G:\MPLAB\Projects\201001.X\source\

std.file.FileException at std\file.d(3368): 
G:\MPLAB\Projects\201001.X\source: The system cannot find the 
path specified.
----------------
0x004101B6 in @safe bool std.file.cenforce!(bool).cenforce(bool, 
lazy const(char)[], immutable(char)[], uint)
0x0043E1C5 in ref std.file.DirIteratorImpl 
std.file.DirIteratorImpl.__ctor!(immutable(char)[]).__ctor(immutable(char)[], std.file.SpanMode, bool)
0x0042417F in nothrow @nogc 
rt.util.container.treap.Treap!(gc.gc.Range).Treap.Node* 
rt.util.container.treap.Treap!(gc.gc.Range).Treap.insert(rt.util.container.treap.Treap!(gc.gc.Range).Treap.Node*, gc.gc.Range)
...

import std.file;
import std.path;
import std.stdio:writeln;

void main(string[] args){
	
	int depth=0;
	int Maxdepth=0;
	
	if(!args[1].buildNormalizedPath.isValidPath){writeln("Path is 
invalid! "); return;}
	
	foreach (string name; dirEntries(args[1].buildNormalizedPath , 
SpanMode.breadth))
	{
		
		int line =1;
		int column = 1;
		depth = 0;
		if(name.isFile){
			writeln(name);
			string myfile = cast(string) std.file.read(name);
			foreach(char C; myfile){
				if(C == '{' ){
					depth+=1;
				}else if (C == '}'){
					depth-=1;
				}else if (C == '\n'){
					line ++;
					column=1;
				}
				if (depth>Maxdepth){
					Maxdepth = depth;
					writeln("In File: ",name," Has a nested depth of: ",depth, " 
at line: ", line, " column: ", column);
				}
				column++;
			}
		}
	}
}


More information about the Digitalmars-d-learn mailing list