Re: Direntries seems to on other drives. (windows)

2016-04-02 Thread Vladimir Panteleev via Digitalmars-d-learn

On Friday, 1 April 2016 at 02:05:23 UTC, Taylor Hillegeist wrote:


Even though i just checked for a valid path.



[...]


	if(!args[1].buildNormalizedPath.isValidPath){writeln("Path is 
invalid! "); return;}


From https://dlang.org/library/std/path/is_valid_path.html :

It does *not* check whether the path points to an existing file 
or directory; use std.file.exists for this purpose.


You are using the wrong function for the job.

The simple explanation is that the path you specified doesn't 
actually exist.


Re: Direntries seems to on other drives. (windows)

2016-03-31 Thread rikki cattermole via Digitalmars-d-learn

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


Direntries seems to on other drives. (windows)

2016-03-31 Thread Taylor Hillegeist via Digitalmars-d-learn


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