On 01/04/2016 3:05 PM, Taylor Hillegeist wrote:

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@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++;
             }
         }
     }
}

Looks like its a bug with WinAPI.

https://social.msdn.microsoft.com/Forums/en-US/8af82029-d4b9-44e4-ab6b-82526460f3ca/findfirstfile-api-fails-over-mapped-drives-windows-vista?forum=os_fileservices

Reply via email to