當前位置: 首頁>>代碼示例>>Java>>正文


Java SanitizedFile.exists方法代碼示例

本文整理匯總了Java中org.fdroid.fdroid.data.SanitizedFile.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java SanitizedFile.exists方法的具體用法?Java SanitizedFile.exists怎麽用?Java SanitizedFile.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.fdroid.fdroid.data.SanitizedFile的用法示例。


在下文中一共展示了SanitizedFile.exists方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: symlink

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
public static boolean symlink(SanitizedFile source, SanitizedFile dest) {

        if (Build.VERSION.SDK_INT >= 21) {
            symlinkOs(source, dest);
        } else if (Build.VERSION.SDK_INT >= 15) {
            symlinkLibcore(source, dest);
        } else {
            symlinkRuntime(source, dest);
        }

        return dest.exists();
    }
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:13,代碼來源:FileCompat.java

示例2: copyApkToFiles

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
/**
 * Copy an APK from {@param apkFile} to our internal files directory for 20 minutes.
 *
 * @param verifyHash If the file was just downloaded, then you should mark this as true and
 *                   request the file to be verified once it has finished copying. Otherwise,
 *                   if the app was installed from part of the system where it can't be tampered
 *                   with (e.g. installed apks on disk) then
 */
private static SanitizedFile copyApkToFiles(Context context, File apkFile, String destinationName,
                                            boolean verifyHash, String hash, String hashType)
        throws IOException {
    SanitizedFile sanitizedApkFile = new SanitizedFile(context.getFilesDir(), destinationName);

    // Don't think this is necessary, but the docs for FileUtils#copyFile() are not clear
    // on whether it overwrites destination files (pretty confident it does, as per the docs
    // in FileUtils#copyFileToDirectory() - which delegates to copyFile()).
    if (sanitizedApkFile.exists()) {
        sanitizedApkFile.delete();
    }

    FileUtils.copyFile(apkFile, sanitizedApkFile);

    // verify copied file's hash with expected hash from Apk class
    if (verifyHash && !Hasher.isFileMatchingHash(sanitizedApkFile, hash, hashType)) {
        FileUtils.deleteQuietly(apkFile);
        throw new IOException(apkFile + " failed to verify!");
    }

    // 20 minutes the start of the install process, delete the file
    final File apkToDelete = sanitizedApkFile;
    new Thread() {
        @Override
        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
            try {
                Thread.sleep(1200000);
            } catch (InterruptedException ignored) {
            } finally {
                FileUtils.deleteQuietly(apkToDelete);
            }
        }
    }.start();

    return sanitizedApkFile;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:46,代碼來源:ApkCache.java

示例3: LocalRepoManager

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
private LocalRepoManager(Context c) {
    context = c.getApplicationContext();
    pm = c.getPackageManager();
    assetManager = c.getAssets();
    fdroidPackageName = c.getPackageName();

    webRoot = SanitizedFile.knownSanitized(c.getFilesDir());
    /* /fdroid/repo is the standard path for user repos */
    fdroidDir = new SanitizedFile(webRoot, "fdroid");
    fdroidDirCaps = new SanitizedFile(webRoot, "FDROID");
    repoDir = new SanitizedFile(fdroidDir, "repo");
    repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO");
    iconsDir = new SanitizedFile(repoDir, "icons");
    xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
    xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");

    if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
        Log.e(TAG, "Unable to create empty base: " + fdroidDir);
    }

    if (!repoDir.exists() && !repoDir.mkdir()) {
        Log.e(TAG, "Unable to create empty repo: " + repoDir);
    }

    if (!iconsDir.exists() && !iconsDir.mkdir()) {
        Log.e(TAG, "Unable to create icons folder: " + iconsDir);
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:29,代碼來源:LocalRepoManager.java

示例4: LocalRepoManager

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
private LocalRepoManager(Context c) {
    context = c.getApplicationContext();
    pm = c.getPackageManager();
    assetManager = c.getAssets();
    fdroidPackageName = c.getPackageName();

    webRoot = SanitizedFile.knownSanitized(c.getFilesDir());
    /* /fdroid/repo is the standard path for user repos */
    fdroidDir = new SanitizedFile(webRoot, "fdroid");
    fdroidDirCaps = new SanitizedFile(webRoot, "FDROID");
    repoDir = new SanitizedFile(fdroidDir, "repo");
    repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO");
    iconsDir = new SanitizedFile(repoDir, "icons");
    xmlIndex = new SanitizedFile(repoDir, "index.xml");
    xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
    xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");

    if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
        Log.e(TAG, "Unable to create empty base: " + fdroidDir);
    }

    if (!repoDir.exists() && !repoDir.mkdir()) {
        Log.e(TAG, "Unable to create empty repo: " + repoDir);
    }

    if (!iconsDir.exists() && !iconsDir.mkdir()) {
        Log.e(TAG, "Unable to create icons folder: " + iconsDir);
    }
}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:30,代碼來源:LocalRepoManager.java

示例5: getApkCacheDir

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
/**
 * This location is only for caching, do not install directly from this location
 * because if the file is on the External Storage, any other app could swap out
 * the APK while the install was in process, allowing malware to install things.
 * Using {@link org.fdroid.fdroid.installer.Installer#installPackage(File, String, String)}
 * is fine since that does the right thing.
 */
public static SanitizedFile getApkCacheDir(Context context) {
    final SanitizedFile apkCacheDir = new SanitizedFile(StorageUtils.getCacheDirectory(context, true), "apks");
    if (!apkCacheDir.exists()) {
        apkCacheDir.mkdir();
    }
    return apkCacheDir;
}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:15,代碼來源:Utils.java


注:本文中的org.fdroid.fdroid.data.SanitizedFile.exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。