mengdiwang / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Files.deleteDirectoryContents() fails for relative directory #498

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, 
I've created a File object from a relative path under windows:
new File("./src/test/resources/target-dir");

I copied some files inside this directory and tried to remove the content with 
Files.deleteDirectoryContents().

It fails silently cause of:
if (!directory.getCanonicalPath().equals(directory.getAbsolutePath())) {
      return;
}

The cause is that directory.getCanonicalPath() returns 
"C:\work\dev\test\src\test\resources\target-dir\tmp"

and directory.getAbsolutePath() returns 
"C:\work\dev\test\.\src\test\resources\target-dir\tmp"

(notice the dot before src)

Original issue reported on code.google.com by christop...@gmail.com on 16 Dec 2010 at 5:38

GoogleCodeExporter commented 9 years ago
I don't yet know if this will be feasible to fix.

Original comment by kevinb@google.com on 12 Jan 2011 at 10:25

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 12 Jan 2011 at 10:32

GoogleCodeExporter commented 9 years ago
Issue #637 is already pointing out the problem with that dain bramaged code. 

Original comment by docw...@gmail.com on 15 Jul 2011 at 10:08

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09