Search in sources :

Example 1 with VirtualFileSystem

use of info.guardianproject.iocipher.VirtualFileSystem in project Zom-Android by zom.

the class SecureMediaStore method init.

/**
 * Careful! All of the {@code File}s in this method are {@link java.io.File}
 * not {@link info.guardianproject.iocipher.File}s
 *
 * @param context
 * @param key
 * @throws IllegalArgumentException
 */
public static void init(Context context, byte[] key) throws IllegalArgumentException {
    // there is only one VFS, so if its already mounted, nothing to do
    VirtualFileSystem vfs = VirtualFileSystem.get();
    if (vfs.isMounted()) {
        Log.w(TAG, "VFS " + vfs.getContainerPath() + " is already mounted, so unmount()");
        try {
            vfs.unmount();
        } catch (Exception e) {
            Log.w(TAG, "VFS " + vfs.getContainerPath() + " issues with unmounting: " + e.getMessage());
        }
    }
    Log.w(TAG, "Mounting VFS: " + vfs.getContainerPath());
    dbFilePath = getInternalDbFilePath(context);
    if (!new java.io.File(dbFilePath).exists()) {
        vfs.createNewContainer(dbFilePath, key);
    }
    try {
        vfs.mount(dbFilePath, key);
    // list("/");
    } catch (Exception e) {
        Log.w(TAG, "VFS " + vfs.getContainerPath() + " issues with mounting: " + e.getMessage());
    }
}
Also used : VirtualFileSystem(info.guardianproject.iocipher.VirtualFileSystem) File(info.guardianproject.iocipher.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

File (info.guardianproject.iocipher.File)1 VirtualFileSystem (info.guardianproject.iocipher.VirtualFileSystem)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1