On Friday, 24 January 2014 at 23:46:04 UTC, Clas Onnebrink wrote:

Hi,

Im a newbie in D and I have a small problem. Thats my method

 //*********************************
   private void searchAndRunAction() {
      foreach (entry;dirEntries(paramPath,
                                paramSearchType,
(paramSwitchRecursiveOn ? SpanMode.breadth : SpanMode.shallow)))
      {
         filesCount++;

         if (isDuplicate(entry.name)) {
            filesDupCount++;
            if (paramSwitchDeleteOn)
               remove(entry.name);
         }

         printProgress(entry.name);
      }
   }

I want work through a directory on my linux server but there are some
directories I have no permissions to access so I get following:

~/Projects/cltools/smdups $ source/smdups -r -p=/media/clas/Elements2 -e=*.* std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): /media/clas/Elements2/lost+found: Permission denied
----------------
/home/clas/Projects/cltools/smdups/source/smdups() [0x43cb1d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x43eab4]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404768]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404116]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404d2d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41a71f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b0b0]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b018]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f66a29c8de5]
/home/clas/Projects/cltools/smdups/source/smdups() [0x403e63]
----------------
~/Projects/cltools/smdups $ std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): /media/clas/Elements2/lost+found: Permission denied std.file.FileException@../../../../src/libphobos/src/std/file.d(2353):: command not found

My question: How to skip any exceptions in dirEntries. I tried it with filter. But no chance. Is there a way to do it like in C# with LINQ-Expressions?

greets

clas

One way would just be to catch the exceptions. Note you may want to activate debug mode to know what functions are actually failing. A FileException is being fired when it cannot do a file operation as detailed in phobos documentation.

Reply via email to