yangxu998 / guava-libraries

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

Files.deleteDirectoryContents(File file) fails when the directory is in the default temp directory in windows #637

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use windows machine
2. Create a temp directory using Files.createTempDir()
3. Add some files
4. Call Files.deleteDirectoryContents(dir)
5. It will exit without deleting the content

What is the expected output? What do you see instead?
The files to be deleted - I was actually using deleteRecursively(File)

What version of the product are you using? On what operating system?
r09

Please provide any additional information below.
The bug is in the following code:
    // Symbolic links will have different canonical and absolute paths
    if (!directory.getCanonicalPath().equals(directory.getAbsolutePath())) {
      return;
    }
since:
directory.getCanonicalPath()=C:\Users\david.MOBIMATE\AppData\Local\Temp\13069349
14921-0
directory.getAbsolutePath()=C:\Users\DAVID~1.MOB\AppData\Local\Temp\130693491492
1-0
But both are the same dir and the different names are because of the windows 
naming.

Original issue reported on code.google.com by david...@gmail.com on 1 Jun 2011 at 1:40

GoogleCodeExporter commented 9 years ago
This might be a dup; I know I've seen problems with this mentally challenged 
check before.  Fortunately for everyone, JDK 7 has a real filesystem library 
for the first time; unfortunately for you now perhaps, this means we don't have 
much motivation to sink more effort into this area of Guava.

If this is very important to anyone, please send us a patch and we will test it 
out.

Original comment by kevinb@google.com on 13 Jul 2011 at 6:54

GoogleCodeExporter commented 9 years ago
How about changing it to include a check for not windows?

This check may be mentally challenged on Unix, but in windows it's the wheel 
maybe spinning but the hamster is dead.

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

GoogleCodeExporter commented 9 years ago

Original comment by cpov...@google.com on 21 Jul 2011 at 6:25

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