Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -76,6 +76,18 @@
76 76 }
77 77 }
78 78
79 + public static File insureParentDirectory( File pExpectedFile )
80 + throws FileSystemException
81 + {
82 + Utils.assertNotNull( "ExpectedFile", pExpectedFile );
83 + File zParentFile = pExpectedFile.getParentFile();
84 + if ( zParentFile != null )
85 + {
86 + insureDirectory( zParentFile );
87 + }
88 + return pExpectedFile;
89 + }
90 +
79 91 public static File insureDirectory( File pExpectedDir )
80 92 throws FileSystemException
81 93 {
  @@ -115,16 +127,12 @@
115 127 {
116 128 Utils.assertNotNull( "SourceFile", pSourceFile );
117 129 Utils.assertNotNull( "TargetFile", pTargetFile );
130 + Throwable zProblem = null;
118 131 try
119 132 {
120 133 if ( pSourceFile.exists() )
121 134 {
122 - File zParent = pTargetFile.getParentFile();
123 - if ( zParent != null )
124 - {
125 - //noinspection ResultOfMethodCallIgnored
126 - zParent.mkdirs();
127 - }
135 + insureParentDirectory( pTargetFile );
128 136 }
129 137 if ( pSourceFile.renameTo( pTargetFile ) )
130 138 {
  @@ -133,12 +141,12 @@
133 141 return;
134 142 }
135 143 }
136 - throw new FileSystemException( "Failed to Move (rename): " + pSourceFile + " to " + pTargetFile );
137 144 }
138 145 catch ( RuntimeException e )
139 146 {
140 - throw new FileSystemException( "Failed to Move (rename): " + pSourceFile + " to " + pTargetFile, e );
147 + zProblem = e;
141 148 }
149 + throw new FileSystemException( "Failed to Move (rename): " + pSourceFile + " to " + pTargetFile, zProblem );
142 150 }
143 151
144 152 public static void deleteIfExists( File pDirectory )