[Issue 6138] Using dirEntries and chdir() can have unwanted results

2018-03-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

Timothee Cour  changed:

   What|Removed |Added

 OS|Windows |All
   Severity|normal  |major

--- Comment #8 from Timothee Cour  ---
ping: this is a serious bug
note: i was OSX and the bug was reported on windows originally, so setting to
All

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2018-02-09 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

--- Comment #7 from Timothee Cour  ---
just hit that bug again, but differently:
```
chdir(foo);
auto files=dirEntries(dirSrc, "*.d",
SpanMode.depth).filter!(a=>a.isFile).map!(a=>dir.buildPath(a.name)).array;
```
crashed similarly

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2018-02-04 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

Seb  changed:

   What|Removed |Added

 CC||greensunn...@gmail.com

--- Comment #6 from Seb  ---
FYI: Francesco Galla submitted a PR - https://github.com/dlang/phobos/pull/6125

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2018-01-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

Francesco Galla'  changed:

   What|Removed |Added

 CC||francesco.gal...@gmail.com

--- Comment #5 from Francesco Galla'  ---
(In reply to RazvanN from comment #3)
> After analyzing the code I see that dirEntries does not call absolutePath on
> the path, which in my opinion is a bug. Even though I cannot reproduce the
> bug, I think a call to absolutePath should definitely be added

I reproduced the bug with the following code:

   foreach (string entry; dirEntries((dir), SpanMode.shallow))
   {
   if (entry.isDir)
   {
foreach (string subentry; dirEntries(entry, SpanMode.shallow))
{
 if (subentry.isDir)
 {
 chdir(absolutePath(subentry));
 writeln (absolutePath(subentry));
 }
}
   }
   }

My directory tree is:

.
├── 1
│   └── 2
├── 3
│   ├── 4
│   └── 5
│   └── 6


* The result I obtained was the following:

std.file.FileException@/opt/dmd-2.075/import/std/file.d(1631): ./3: No such
file or directory

* By calling:

foreach (string entry; dirEntries(absolutePath(dir), SpanMode.shallow))

The code was executed correctly. This seems to confirm the need for
dirEntries() to call absolutePath(). Am I mistaken?

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2017-07-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

--- Comment #4 from Vladimir Panteleev  ---
(In reply to RazvanN from comment #3)
> After analyzing the code I see that dirEntries does not call absolutePath on
> the path, which in my opinion is a bug. Even though I cannot reproduce the
> bug, I think a call to absolutePath should definitely be added

That might break things.

~ $ mkdir -p a/b/c
~ $ cd a/b/c
~/a/b/c $ touch a
~/a/b/c $ ls
a
~/a/b/c $ ls ~/a/b/c
a
~/a/b/c $ chmod 000 ~/a/b
~/a/b/c $ ls
a
~/a/b/c $ ls ~/a/b/c
ls: cannot access '/home/vladimir/a/b/c': Permission denied
~/a/b/c $ 

I think the correct solution would be to use fdopendir and openat (on POSIX).

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2017-07-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

--- Comment #3 from RazvanN  ---
After analyzing the code I see that dirEntries does not call absolutePath on
the path, which in my opinion is a bug. Even though I cannot reproduce the bug,
I think a call to absolutePath should definitely be added

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2017-07-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

RazvanN  changed:

   What|Removed |Added

 CC||razvan.nitu1...@gmail.com

--- Comment #2 from RazvanN  ---
Is this still valid? The code seems to have changes significantly (rel2abs
doesn't exist anymore) and I cannot reproduce with std.file.absolutePath.

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2016-10-14 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

Andrei Alexandrescu  changed:

   What|Removed |Added

   Keywords||bootcamp
 CC||and...@erdani.com

--


[Issue 6138] Using dirEntries and chdir() can have unwanted results

2016-03-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6138

Timothee Cour  changed:

   What|Removed |Added

 CC||timothee.co...@gmail.com

--- Comment #1 from Timothee Cour  ---
sounds like a bug (and one that could cause harm); 
why not have dirEntries call rel2abs ? the cost of this should be dwarfed by
system calls involved in dirEntries

--