OSDN Git Service

FileHandle.moveTo() Update
authorPsyfire <psy@psyfire.com>
Fri, 7 Jun 2013 13:52:15 +0000 (09:52 -0400)
committerPsyfire <psy@psyfire.com>
Fri, 7 Jun 2013 13:52:15 +0000 (09:52 -0400)
delete() only deletes files and empty directories.  As such, moveTo() would leave the old directory after a moveTo() opperation.  By adding deleteDirectory(), this ensures the old copy is removed.  Not sure if the test "if (exists () && isDirectory())" is needed.

gdx/src/com/badlogic/gdx/files/FileHandle.java

index 5f0f145..3ddac64 100644 (file)
@@ -576,6 +576,7 @@ public class FileHandle {
                if (type == FileType.Internal) throw new GdxRuntimeException("Cannot move an internal file: " + file);\r
                copyTo(dest);\r
                delete();\r
+               if (exists () && isDirectory()) deleteDirectory();\r
        }\r
 \r
        /** Returns the length in bytes of this file, or 0 if this file is a directory, does not exist, or the size cannot otherwise be\r