MCPcopy Create free account
hub / github.com/buggins/coolreader / scan

Method scan

android/src/org/coolreader/crengine/Scanner.java:272–325  ·  view source on GitHub ↗
( FileInfo baseDir )

Source from the content-addressed store, hash-verified

270 }
271
272 public void scan( FileInfo baseDir ) {
273 if ( baseDir.isRecentDir() )
274 return;
275 //listDirectory(baseDir);
276 progress(1000);
277 if ( scanControl.isStopped() )
278 return;
279 for ( int i=baseDir.dirCount()-1; i>=0; i-- ) {
280 if ( scanControl.isStopped() )
281 return;
282 listDirectory(baseDir.getDir(i));
283 }
284 progress(2000);
285 if ( mHideEmptyDirs )
286 baseDir.removeEmptyDirs();
287 if ( scanControl.isStopped() )
288 return;
289 ArrayList<FileInfo> filesForParsing = new ArrayList<FileInfo>();
290 int count = baseDir.fileCount();
291 for ( int i=0; i<count; i++ ) {
292 FileInfo item = baseDir.getFile(i);
293 boolean found = db.findByPathname(item);
294 if ( found )
295 Log.v("cr3db", "File " + item.pathname + " is found in DB (id="+item.id+", title=" + item.title + ", authors=" + item.authors +")");
296
297 boolean saveToDB = true;
298 if ( !found && item.format.canParseProperties() ) {
299 filesForParsing.add(item);
300 saveToDB = false;
301 }
302
303 if ( !found && saveToDB ) {
304 db.save(item);
305 Log.v("cr3db", "File " + item.pathname + " is added to DB (id="+item.id+", title=" + item.title + ", authors=" + item.authors +")");
306 }
307 progress( 2000 + 3000 * i / count );
308 }
309 // db lookup files
310 count = filesForParsing.size();
311 for ( int i=0; i<count; i++ ) {
312 if ( scanControl.isStopped() )
313 return;
314 FileInfo item = filesForParsing.get(i);
315 engine.scanBookProperties(item);
316 booksToSave.add(item);
317 progress( 5000 + 5000 * i / count );
318 }
319 if ( recursiveScan ) {
320 if ( scanControl.isStopped() )
321 return;
322 for ( int i=baseDir.dirCount()-1; i>=0; i-- )
323 scan(baseDir.getDir(i));
324 }
325 }
326
327 public void work() throws Exception {
328 // scan (list) directories

Callers 1

workMethod · 0.95

Calls 15

progressMethod · 0.95
listDirectoryMethod · 0.95
isStoppedMethod · 0.80
dirCountMethod · 0.80
getDirMethod · 0.80
removeEmptyDirsMethod · 0.80
fileCountMethod · 0.80
getFileMethod · 0.80
findByPathnameMethod · 0.80
canParsePropertiesMethod · 0.80
scanBookPropertiesMethod · 0.80
vMethod · 0.65

Tested by

no test coverage detected