Make UniFile actually backed by ParcelFileDescriptor, implement IO stream as extensions, Resolve #896

This commit is contained in:
tarsin committed 2023-02-27 18:13:00 +08:00
1 parent 24ccf60870
commit 3973f5ef70
12 files changed
+82 -276

No files matched your search

@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -29,8 +30,6 @@ import com.hippo.image.Image;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -414,35 +413,9 @@ public abstract class UniFile {
*/
public abstract boolean renameTo(String displayName);
/**
* Open a stream on to the content associated with the file, clean it if it exists
*
* @return the {@link OutputStream}
* @throws IOException
*/
@NonNull
public abstract OutputStream openOutputStream() throws IOException;
/**
* Open a stream on to the content associated with the file
*
* @param append {@code true} for do not clean it if it exists
* @return the {@link OutputStream}
* @throws IOException
*/
@NonNull
public abstract OutputStream openOutputStream(boolean append) throws IOException;
/**
* Open a stream on to the content associated with the file
*
* @return the {@link InputStream}
* @throws IOException
*/
@NonNull
public abstract InputStream openInputStream() throws IOException;
@NonNull
public abstract Image.CloseableSource getImageSource();
@NonNull
public abstract ParcelFileDescriptor openFileDescriptor(@NonNull String mode) throws IOException;
}