digitalmars.D.learn - [Help]How to handle exception from dirEntries?
- Keqin (44/45) Jun 16 2014 Hi everyone,
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/12) Jun 16 2014 Known issue:
- Keqin (2/16) Jun 16 2014
Hi everyone, I have write a short program to check file size recursively as bellow. If i run this exe on windows eg.:hello.exe --dir C:\It will throw as: std.file.FileException std\file.d(2519): C:\$Recycle.Bin\S-1-5-18: Access is den ied. I believe the exception comes from the following line: auto entries = dirEntries(dirpath, SpanMode.depth); I have read the std.file, still have no idea how to get around of it. Can someone help? ..code-block: d import std.stdio; import std.file; import std.getopt; string dirpath="."; void main(string[] args) { getopt(args, "dir", &dirpath); writeln(dirpath); auto entries = dirEntries(dirpath, SpanMode.depth); writeln("start while"); while(!entries.empty) { try{ auto entry = entries.front; if(entry.isFile()) { writeln(getSize(entry)); } entries.popFront(); } catch(FileException o){ //handle FileException } catch(Exception o){ //handle all other types of exceptions } finally{ //do nothing } } }
Jun 16 2014
On 06/16/2014 09:44 PM, Keqin wrote:> Hi everyone,std.file.FileException std\file.d(2519): C:\$Recycle.Bin\S-1-5-18: Access is den ied. I believe the exception comes from the following line: auto entries = dirEntries(dirpath, SpanMode.depth);Known issue: https://issues.dlang.org/show_bug.cgi?id=12391 Also see: https://issues.dlang.org/show_bug.cgi?id=8967 https://issues.dlang.org/show_bug.cgi?id=6138 Ali
Jun 16 2014
Thanks for your reply! On Tuesday, 17 June 2014 at 04:50:43 UTC, Ali Çehreli wrote:On 06/16/2014 09:44 PM, Keqin wrote:> Hi everyone,std.file.FileException std\file.d(2519):C:\$Recycle.Bin\S-1-5-18:Access is den ied. I believe the exception comes from the following line: auto entries = dirEntries(dirpath, SpanMode.depth);Known issue: https://issues.dlang.org/show_bug.cgi?id=12391 Also see: https://issues.dlang.org/show_bug.cgi?id=8967 https://issues.dlang.org/show_bug.cgi?id=6138 Ali
Jun 16 2014