Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -8,6 +8,12 @@
8 8
9 9 public abstract class AbstractFileAR
10 10 {
11 + private static final Character DIR_MOVED = 'O';
12 + private static final Character FILE_MOVED = 'o';
13 + private static final Character FILE_UPDATED = 'u';
14 + private static final Character FILE_COPY_ADDED = 'n';
15 + private static final Character SILENT_THRESHOLD = '.';
16 +
11 17 private void showHelp()
12 18 {
13 19 System.out.println( "Requires a minimum of 4 parameters:" );
  @@ -19,6 +25,29 @@
19 25 System.exit( 1 );
20 26 }
21 27
28 + private int mNotifications = 0;
29 + private int mSilentChecks = 0;
30 +
31 + private void notify( Character pWhat )
32 + {
33 + if ( pWhat == null )
34 + {
35 + if ( ++mSilentChecks < 50 )
36 + {
37 + return;
38 + }
39 + mSilentChecks = 0;
40 + pWhat = SILENT_THRESHOLD;
41 + }
42 + System.out.print( pWhat );
43 + if ( ++mNotifications >= 80 )
44 + {
45 + System.out.println();
46 + mNotifications = 0;
47 + }
48 + }
49 +
50 +
22 51 protected void process( String pName, String pVersion, String[] args )
23 52 {
24 53 System.out.println( pName + " vs " + pVersion );
  @@ -83,11 +112,14 @@
83 112 }
84 113 for (; source != null; source = getNextOrNull( sources ) )
85 114 {
86 - copyAddFile( pSourcePath, pDestinationPath, source );
115 + File zSourcePath = new File( pSourcePath, source );
116 + File zDestinationPath = new File( pDestinationPath, source );
117 + File zXtraFilesPath = new File( pXtraFilesPath, source );
118 + process( zSourcePath, zDestinationPath, zXtraFilesPath, pFilePatterns );
87 119 }
88 120 for (; dest != null; dest = getNextOrNull( destination ) )
89 121 {
90 - moveFileForced( pDestinationPath, pXtraFilesPath, dest );
122 + notify( moveFileForced( pDestinationPath, pXtraFilesPath, dest ) );
91 123 }
92 124 }
93 125
  @@ -105,28 +137,28 @@
105 137 int i = source.compareTo( dest );
106 138 if ( i == 0 ) // Equal
107 139 {
108 - updateFile( pSourcePath, pDestinationPath, source );
140 + notify( updateFile( pSourcePath, pDestinationPath, source ) );
109 141 source = getNextOrNull( sources );
110 142 dest = getNextOrNull( destination );
111 143 }
112 144 else if ( i < 0 ) // source < dest
113 145 {
114 - copyAddFile( pSourcePath, pDestinationPath, source );
146 + notify( copyAddFile( pSourcePath, pDestinationPath, source ) );
115 147 source = getNextOrNull( sources );
116 148 }
117 149 else // source > dest
118 150 {
119 - moveFileForced( pDestinationPath, pXtraFilesPath, dest );
151 + notify( moveFileForced( pDestinationPath, pXtraFilesPath, dest ) );
120 152 dest = getNextOrNull( destination );
121 153 }
122 154 }
123 155 for (; source != null; source = getNextOrNull( sources ) )
124 156 {
125 - copyAddFile( pSourcePath, pDestinationPath, source );
157 + notify( copyAddFile( pSourcePath, pDestinationPath, source ) );
126 158 }
127 159 for (; dest != null; dest = getNextOrNull( destination ) )
128 160 {
129 - moveFileForced( pDestinationPath, pXtraFilesPath, dest );
161 + notify( moveFileForced( pDestinationPath, pXtraFilesPath, dest ) );
130 162 }
131 163 }
132 164
  @@ -167,55 +199,49 @@
167 199 return pIterator.hasNext() ? pIterator.next() : null;
168 200 }
169 201
170 - protected void moveDirForced( File pSourcePath, File pDestinationPath )
202 + protected Character moveDirForced( File pSourcePath, File pDestinationPath )
171 203 {
172 - System.out.print( 'O' );
173 - moveDir( pSourcePath, pDestinationPath );
204 + return moveDir( pSourcePath, pDestinationPath ) ? DIR_MOVED : null;
174 205 }
175 206
176 - protected void moveFileForced( File pSourcePath, File pDestinationPath, String pFileName )
207 + protected Character moveFileForced( File pSourcePath, File pDestinationPath, String pFileName )
177 208 {
178 - System.out.print( 'o' );
179 209 File source = new File( pSourcePath, pFileName );
180 210 File dest = new File( pDestinationPath, pFileName );
181 - moveFile( source, dest );
211 + return moveFile( source, dest ) ? FILE_MOVED : null;
182 212 }
183 213
184 - protected void updateFile( File pSourcePath, File pDestinationPath, String pFileName )
214 + protected Character updateFile( File pSourcePath, File pDestinationPath, String pFileName )
185 215 {
186 - System.out.print( 'u' );
187 216 File source = new File( pSourcePath, pFileName );
188 217 File dest = new File( pDestinationPath, pFileName );
189 - updateFile( source, dest );
190 - FileUtils.deleteIfExists( source );
218 + return updateFile( source, dest ) ? FILE_UPDATED : null;
191 219 }
192 220
193 - protected void copyAddFile( File pSourcePath, File pDestinationPath, String pFileName )
221 + protected Character copyAddFile( File pSourcePath, File pDestinationPath, String pFileName )
194 222 {
195 - System.out.print( 'n' );
196 223 File source = new File( pSourcePath, pFileName );
197 224 File dest = new File( pDestinationPath, pFileName );
198 - copyAddFile( source, dest );
199 - FileUtils.deleteIfExists( source );
225 + return copyAddFile( source, dest ) ? FILE_COPY_ADDED : null;
200 226 }
201 227
202 228 /**
203 229 * Move Dir - Assume same volume!
204 230 */
205 - abstract protected void moveDir( File pSource, File pDestination );
231 + abstract protected boolean moveDir( File pSource, File pDestination );
206 232
207 233 /**
208 234 * Move File - Assume same volume!
209 235 */
210 - abstract protected void moveFile( File pSource, File pDestination );
236 + abstract protected boolean moveFile( File pSource, File pDestination );
211 237
212 238 /**
213 239 * Update the existing pDestination from the pSource - Assume NOT the same volume!
214 240 */
215 - abstract protected void updateFile( File pSource, File pDestination );
241 + abstract protected boolean updateFile( File pSource, File pDestination );
216 242
217 243 /**
218 244 * Copy the pSource to the pDestination - Assume NOT the same volume!
219 245 */
220 - abstract protected void copyAddFile( File pSource, File pDestination );
246 + abstract protected boolean copyAddFile( File pSource, File pDestination );
221 247 }