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

Method checkOrMoveFile

android/src/org/coolreader/crengine/Engine.java:858–876  ·  view source on GitHub ↗

Checks whether file under old path exists, and moves it to better place when necessary. Can be slow if big file is being moved. @param bestPlace is desired directory for file (e.g. new place after migration) @param oldPlace is old (obsolete) directory for file (e.g. location from older releases) @pa

( File bestPlace, File oldPlace, String filename )

Source from the content-addressed store, hash-verified

856 * @return file to use (from old or new place)
857 */
858 public static File checkOrMoveFile( File bestPlace, File oldPlace, String filename ) {
859 if ( !bestPlace.exists() ) {
860 bestPlace.mkdirs();
861 }
862 File oldFile = new File(oldPlace, filename);
863 if ( bestPlace.isDirectory() && bestPlace.canWrite() ) {
864 File bestFile = new File(bestPlace, filename);
865 if (bestFile.exists())
866 return bestFile; // already exists
867 if (oldFile.exists() && oldFile.isFile()) {
868 // move file
869 if (moveFile(oldFile, bestFile))
870 return bestFile;
871 return oldFile;
872 }
873 return bestFile;
874 }
875 return oldFile;
876 }
877
878 private static String CR3_SETTINGS_DIR_NAME;
879

Callers 2

onCreateMethod · 0.95
loadSettingsMethod · 0.95

Calls 2

moveFileMethod · 0.95
existsMethod · 0.80

Tested by

no test coverage detected