Stop always opening files in write mode
This commit is contained in:
parent
8c9c6a20b9
commit
49ec2eaf49
@ -481,8 +481,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
|
|||||||
CustomAlertDialogBuilder(this@CameraActivity, theme)
|
CustomAlertDialogBuilder(this@CameraActivity, theme)
|
||||||
.setTitle(R.string.error)
|
.setTitle(R.string.error)
|
||||||
.setMessage(R.string.picture_save_failed)
|
.setMessage(R.string.picture_save_failed)
|
||||||
.setCancelable(false)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setPositiveButton(R.string.ok) { _, _ -> finish() }
|
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,6 +501,15 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
|
|||||||
videoRecording?.stop()
|
videoRecording?.stop()
|
||||||
} else if (!isWaitingForTimer) {
|
} else if (!isWaitingForTimer) {
|
||||||
val path = getOutputPath(true)
|
val path = getOutputPath(true)
|
||||||
|
val fileHandle = encryptedVolume.openFileWriteMode(path)
|
||||||
|
if (fileHandle == -1L) {
|
||||||
|
CustomAlertDialogBuilder(this, theme)
|
||||||
|
.setTitle(R.string.error)
|
||||||
|
.setMessage(R.string.file_creation_failed)
|
||||||
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
.show()
|
||||||
|
return
|
||||||
|
}
|
||||||
startTimerThen {
|
startTimerThen {
|
||||||
var withAudio = true
|
var withAudio = true
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
@ -513,7 +521,6 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
|
|||||||
this,
|
this,
|
||||||
MuxerOutputOptions(
|
MuxerOutputOptions(
|
||||||
FFmpegMuxer(object : SeekableWriter {
|
FFmpegMuxer(object : SeekableWriter {
|
||||||
private val fileHandle = encryptedVolume.openFile(path)
|
|
||||||
private var offset = 0L
|
private var offset = 0L
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
@ -241,7 +241,7 @@ class ExplorerActivity : BaseExplorerActivity() {
|
|||||||
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
} else {
|
||||||
val filePath = PathUtils.pathJoin(currentDirectoryPath, fileName)
|
val filePath = PathUtils.pathJoin(currentDirectoryPath, fileName)
|
||||||
val handleID = encryptedVolume.openFile(filePath)
|
val handleID = encryptedVolume.openFileWriteMode(filePath)
|
||||||
if (handleID == -1L) {
|
if (handleID == -1L) {
|
||||||
CustomAlertDialogBuilder(this, theme)
|
CustomAlertDialogBuilder(this, theme)
|
||||||
.setTitle(R.string.error)
|
.setTitle(R.string.error)
|
||||||
|
@ -125,9 +125,9 @@ class FileOperationService : Service() {
|
|||||||
|
|
||||||
private fun copyFile(srcPath: String, dstPath: String, remoteEncryptedVolume: EncryptedVolume = encryptedVolume): Boolean {
|
private fun copyFile(srcPath: String, dstPath: String, remoteEncryptedVolume: EncryptedVolume = encryptedVolume): Boolean {
|
||||||
var success = true
|
var success = true
|
||||||
val srcFileHandle = remoteEncryptedVolume.openFile(srcPath)
|
val srcFileHandle = remoteEncryptedVolume.openFileReadMode(srcPath)
|
||||||
if (srcFileHandle != -1L) {
|
if (srcFileHandle != -1L) {
|
||||||
val dstFileHandle = encryptedVolume.openFile(dstPath)
|
val dstFileHandle = encryptedVolume.openFileWriteMode(dstPath)
|
||||||
if (dstFileHandle != -1L) {
|
if (dstFileHandle != -1L) {
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
val ioBuffer = ByteArray(Constants.IO_BUFF_SIZE)
|
val ioBuffer = ByteArray(Constants.IO_BUFF_SIZE)
|
||||||
|
@ -15,7 +15,7 @@ class EncryptedVolumeDataSource(private val encryptedVolume: EncryptedVolume, pr
|
|||||||
private var bytesRemaining: Long = -1
|
private var bytesRemaining: Long = -1
|
||||||
|
|
||||||
override fun open(dataSpec: DataSpec): Long {
|
override fun open(dataSpec: DataSpec): Long {
|
||||||
fileHandle = encryptedVolume.openFile(filePath)
|
fileHandle = encryptedVolume.openFileReadMode(filePath)
|
||||||
fileOffset = dataSpec.position
|
fileOffset = dataSpec.position
|
||||||
val fileSize = encryptedVolume.getAttr(filePath)!!.size
|
val fileSize = encryptedVolume.getAttr(filePath)!!.size
|
||||||
bytesRemaining = if (dataSpec.length == C.LENGTH_UNSET.toLong()) {
|
bytesRemaining = if (dataSpec.length == C.LENGTH_UNSET.toLong()) {
|
||||||
|
@ -67,7 +67,7 @@ class TextEditor: FileViewerActivity() {
|
|||||||
private fun save(): Boolean{
|
private fun save(): Boolean{
|
||||||
var success = false
|
var success = false
|
||||||
val content = editor.text.toString().toByteArray()
|
val content = editor.text.toString().toByteArray()
|
||||||
val fileHandle = encryptedVolume.openFile(filePath)
|
val fileHandle = encryptedVolume.openFileWriteMode(filePath)
|
||||||
if (fileHandle != -1L) {
|
if (fileHandle != -1L) {
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
while (offset < content.size && encryptedVolume.write(fileHandle, offset, content, offset, content.size.toLong()).also { offset += it } > 0) {}
|
while (offset < content.size && encryptedVolume.write(fileHandle, offset, content, offset, content.size.toLong()).also { offset += it } > 0) {}
|
||||||
|
@ -94,7 +94,11 @@ class CryfsVolume(private val fusePtr: Long): EncryptedVolume() {
|
|||||||
writeLong(fusePtr)
|
writeLong(fusePtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openFile(path: String): Long {
|
override fun openFileReadMode(path: String): Long {
|
||||||
|
return nativeOpen(fusePtr, path, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openFileWriteMode(path: String): Long {
|
||||||
val fileHandle = nativeOpen(fusePtr, path, 0)
|
val fileHandle = nativeOpen(fusePtr, path, 0)
|
||||||
return if (fileHandle == -1L) {
|
return if (fileHandle == -1L) {
|
||||||
nativeCreate(fusePtr, path, 0)
|
nativeCreate(fusePtr, path, 0)
|
||||||
|
@ -73,7 +73,8 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
|
|
||||||
override fun describeContents() = 0
|
override fun describeContents() = 0
|
||||||
|
|
||||||
abstract fun openFile(path: String): Long
|
abstract fun openFileReadMode(path: String): Long
|
||||||
|
abstract fun openFileWriteMode(path: String): Long
|
||||||
abstract fun read(fileHandle: Long, fileOffset: Long, buffer: ByteArray, dstOffset: Long, length: Long): Int
|
abstract fun read(fileHandle: Long, fileOffset: Long, buffer: ByteArray, dstOffset: Long, length: Long): Int
|
||||||
abstract fun write(fileHandle: Long, fileOffset: Long, buffer: ByteArray, srcOffset: Long, length: Long): Int
|
abstract fun write(fileHandle: Long, fileOffset: Long, buffer: ByteArray, srcOffset: Long, length: Long): Int
|
||||||
abstract fun closeFile(fileHandle: Long): Boolean
|
abstract fun closeFile(fileHandle: Long): Boolean
|
||||||
@ -106,7 +107,7 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
|
|
||||||
fun exportFile(src_path: String, os: OutputStream): Boolean {
|
fun exportFile(src_path: String, os: OutputStream): Boolean {
|
||||||
var success = false
|
var success = false
|
||||||
val srcfileHandle = openFile(src_path)
|
val srcfileHandle = openFileReadMode(src_path)
|
||||||
if (srcfileHandle != -1L) {
|
if (srcfileHandle != -1L) {
|
||||||
success = exportFile(srcfileHandle, os)
|
success = exportFile(srcfileHandle, os)
|
||||||
closeFile(srcfileHandle)
|
closeFile(srcfileHandle)
|
||||||
@ -127,7 +128,7 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun importFile(inputStream: InputStream, dst_path: String): Boolean {
|
fun importFile(inputStream: InputStream, dst_path: String): Boolean {
|
||||||
val dstfileHandle = openFile(dst_path)
|
val dstfileHandle = openFileWriteMode(dst_path)
|
||||||
if (dstfileHandle != -1L) {
|
if (dstfileHandle != -1L) {
|
||||||
var success = true
|
var success = true
|
||||||
var offset: Long = 0
|
var offset: Long = 0
|
||||||
@ -169,7 +170,7 @@ abstract class EncryptedVolume: Parcelable {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val fileBuff = ByteArray(fileSize.toInt())
|
val fileBuff = ByteArray(fileSize.toInt())
|
||||||
val fileHandle = openFile(fullPath)
|
val fileHandle = openFileReadMode(fullPath)
|
||||||
if (fileHandle == -1L) {
|
if (fileHandle == -1L) {
|
||||||
Pair(null, 3)
|
Pair(null, 3)
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,7 +91,11 @@ class GocryptfsVolume(private val sessionID: Int): EncryptedVolume() {
|
|||||||
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readInt())
|
constructor(parcel: Parcel) : this(parcel.readInt())
|
||||||
|
|
||||||
override fun openFile(path: String): Long {
|
override fun openFileReadMode(path: String): Long {
|
||||||
|
return native_open_read_mode(sessionID, path).toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openFileWriteMode(path: String): Long {
|
||||||
return native_open_write_mode(sessionID, path, 384).toLong() // 0600
|
return native_open_write_mode(sessionID, path, 384).toLong() // 0600
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,7 @@
|
|||||||
#Wed Feb 01 20:48:39 UTC 2023
|
#Wed Feb 01 20:48:39 UTC 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||||
|
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
Loading…
Reference in New Issue
Block a user