use of info.guardianproject.iocipher.File in project Zom-Android by zom.
the class SecureMediaStore method copyToExternal.
public static void copyToExternal(String sourcePath, java.io.File targetPath) throws IOException {
// copy
FileInputStream fis = new FileInputStream(new File(sourcePath));
java.io.FileOutputStream fos = new java.io.FileOutputStream(targetPath, false);
IOUtils.copyLarge(fis, fos);
fos.close();
fis.close();
}
use of info.guardianproject.iocipher.File in project Zom-Android by zom.
the class SecureMediaStore method createUniqueFilename.
private static String createUniqueFilename(String filename) {
if (!exists(filename)) {
return filename;
}
int count = 1;
String uniqueName;
File file;
do {
uniqueName = formatUnique(filename, count++);
file = new File(uniqueName);
} while (file.exists());
return uniqueName;
}
use of info.guardianproject.iocipher.File in project Zom-Android by zom.
the class SecureMediaStore method delete.
private static void delete(String parentName) throws IOException {
File parent = new File(parentName);
// if a file or an empty directory - delete it
if (!parent.isDirectory() || parent.list().length == 0) {
// Log.e(TAG, "delete:" + parent );
if (!parent.delete()) {
throw new IOException("Error deleting " + parent);
}
return;
}
// directory - recurse
String[] list = parent.list();
for (int i = 0; i < list.length; i++) {
String childName = parentName + "/" + list[i];
delete(childName);
}
delete(parentName);
}
use of info.guardianproject.iocipher.File in project Zom-Android by zom.
the class SecureMediaStore method deleteSession.
public static void deleteSession(String sessionId) throws IOException {
String dirName = "/" + sessionId;
File file = new File(dirName);
// if the session doesnt have any ul/dl files - bail
if (!file.exists()) {
return;
}
// delete recursive
delete(dirName);
}
use of info.guardianproject.iocipher.File in project Zom-Android by zom.
the class AudioWife method initPlayer.
/**
**
* Initialize and prepare the audio player
***
*/
private void initPlayer(Context ctx, final Uri mediaUri, String mimeType) throws IOException {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
if (mediaUri.getScheme() != null) {
if (mediaUri.getScheme().equals("vfs")) {
final info.guardianproject.iocipher.File fileMediaEncrypted = new info.guardianproject.iocipher.File(mediaUri.getPath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mMediaPlayer.setDataSource(new MediaDataSource() {
final info.guardianproject.iocipher.RandomAccessFile fis = new info.guardianproject.iocipher.RandomAccessFile(fileMediaEncrypted, "r");
@Override
public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
if (position > getSize())
return -1;
fis.seek(position);
byte[] outBuffer = new byte[size];
int readSize = fis.read(outBuffer, 0, size);
System.arraycopy(outBuffer, 0, buffer, offset, size);
return readSize;
}
@Override
public long getSize() throws IOException {
return fis.length();
}
@Override
public void close() throws IOException {
if (fis != null)
fis.close();
}
});
} else {
HttpMediaStreamer streamer = new HttpMediaStreamer(fileMediaEncrypted, mimeType);
Uri uri = streamer.getUri();
mMediaPlayer.setDataSource(ctx, uri);
}
} else if (mediaUri.getScheme().equals("content")) {
mMediaPlayer.setDataSource(ctx, mediaUri);
} else if (mediaUri.getScheme().equals("file")) {
mMediaPlayer.setDataSource(ctx, mediaUri);
}
} else {
mMediaPlayer.setDataSource(mediaUri.getPath());
}
try {
mMediaPlayer.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
mMediaPlayer.setOnCompletionListener(mOnCompletion);
}
Aggregations