Subversion Repository Public Repository

litesoft

Diff Revisions 49 vs 64 for /trunk/Java/core/Server/src/org/litesoft/util/DirectoryUtils.java

Diff revisions: vs.
  @@ -95,10 +95,29 @@
95 95 for ( File zFile : zFiles )
96 96 {
97 97 String zName = zFile.getName();
98 - if ( !zFile.renameTo( new File( zTo, zName ) ) )
98 + moveFile( zFile, new File( zTo, zName ) );
99 + }
100 + }
101 +
102 + public static void moveFile( File zSourceFile, File zTargetFile )
103 + throws FileSystemException
104 + {
105 + Utils.assertNotNull( "SourceFile", zSourceFile );
106 + Utils.assertNotNull( "TargetFile", zTargetFile );
107 + try
108 + {
109 + if ( zSourceFile.renameTo( zTargetFile ) )
99 110 {
100 - throw new FileSystemException( "Failed to Move (rename): " + zName );
111 + if ( zTargetFile.exists() )
112 + {
113 + return;
114 + }
101 115 }
116 + throw new FileSystemException( "Failed to Move (rename): " + zSourceFile + " to " + zTargetFile );
117 + }
118 + catch ( RuntimeException e )
119 + {
120 + throw new FileSystemException( "Failed to Move (rename): " + zSourceFile + " to " + zTargetFile, e );
102 121 }
103 122 }
104 123