Skip to content

Commit 6a4a87a

Browse files
committed
WIP: Feat: Re-implement file system abstraction with filesystem-kt
1 parent 42353c9 commit 6a4a87a

123 files changed

Lines changed: 8321 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dependencies {
121121
dependencies {
122122
implementation fileTree(dir: 'libs', include: ['*.jar'])
123123

124-
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
124+
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs_nio:2.1.5")
125125

126126
// kotlinx-coroutines-android depends on kotlin-stdlib-jdk8
127127
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
@@ -201,6 +201,7 @@ dependencies {
201201
implementation 'me.zhanghai.android.libselinux:library:2.1.1'
202202
implementation 'me.zhanghai.android.retrofile:library:1.2.0'
203203
implementation 'me.zhanghai.android.systemuihelper:library:1.0.0'
204+
implementation 'com.github.zhanghai.filesystem-kt:filesystem:82c2592a41'
204205
implementation 'org.apache.ftpserver:ftpserver-core:1.2.1'
205206
// This is a dependency of org.apache.ftpserver:ftpserver-core but org.apache.mina:mina-core
206207
// 2.1.4+ became incompatible before API 24 due to dependency on StandardSocketOptions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
import me.zhanghai.android.files.util.RemoteCallback;
10+
11+
interface IRemoteAsyncCloseableFlow {
12+
void collect(in RemoteCallback callback);
13+
14+
void close(out ParcelableException exception);
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
10+
interface IRemoteFileContent {
11+
long readAtMostTo(
12+
long position,
13+
out byte[] sink,
14+
long byteCount,
15+
out ParcelableException exception
16+
);
17+
18+
void write(long position, in byte[] source, long byteCount, out ParcelableException exception);
19+
20+
long getSize(out ParcelableException exception);
21+
22+
void setSize(long size, out ParcelableException exception);
23+
24+
void sync(out ParcelableException exception);
25+
26+
void close(out ParcelableException exception);
27+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.IRemoteFileContent;
9+
import me.zhanghai.android.files.filesystem.remote.IRemoteFileWatcher;
10+
import me.zhanghai.android.files.filesystem.remote.IRemotePosixFileMetadataView;
11+
import me.zhanghai.android.files.filesystem.remote.IRemotePosixFileStore;
12+
import me.zhanghai.android.files.filesystem.remote.IRemoteRawAsyncSink;
13+
import me.zhanghai.android.files.filesystem.remote.IRemoteRawAsyncSource;
14+
import me.zhanghai.android.files.filesystem.remote.ParcelableDirectoryStream;
15+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
16+
import me.zhanghai.android.files.filesystem.remote.ParcelerParcelable;
17+
18+
interface IRemoteFileSystem {
19+
ParcelerParcelable getRealPath(in ParcelerParcelable file, out ParcelableException exception);
20+
21+
void checkAccess(
22+
in ParcelerParcelable file,
23+
in ParcelerParcelable modes,
24+
out ParcelableException exception
25+
);
26+
27+
IRemotePosixFileMetadataView openMetadataView(
28+
in ParcelerParcelable file,
29+
in ParcelerParcelable options,
30+
out ParcelableException exception
31+
);
32+
33+
ParcelerParcelable readMetadata(
34+
in ParcelerParcelable file,
35+
in ParcelerParcelable options,
36+
out ParcelableException exception
37+
);
38+
39+
IRemoteFileContent openContent(
40+
in ParcelerParcelable file,
41+
in ParcelerParcelable options,
42+
out ParcelableException exception
43+
);
44+
45+
IRemoteRawAsyncSource openSource(
46+
in ParcelerParcelable file,
47+
in ParcelerParcelable options,
48+
out ParcelableException exception
49+
);
50+
51+
IRemoteRawAsyncSink openSink(
52+
in ParcelerParcelable file,
53+
in ParcelerParcelable options,
54+
out ParcelableException exception
55+
);
56+
57+
ParcelableDirectoryStream openDirectoryStream(
58+
in ParcelerParcelable directory,
59+
in ParcelerParcelable options,
60+
out ParcelableException exception
61+
);
62+
63+
ParcelerParcelable readDirectory(
64+
in ParcelerParcelable directory,
65+
in ParcelerParcelable options,
66+
out ParcelableException exception
67+
);
68+
69+
void createDirectory(
70+
in ParcelerParcelable directory,
71+
in ParcelerParcelable options,
72+
out ParcelableException exception
73+
);
74+
75+
ParcelerParcelable readSymbolicLink(
76+
in ParcelerParcelable link,
77+
out ParcelableException exception
78+
);
79+
80+
void createSymbolicLink(
81+
in ParcelerParcelable link,
82+
in ParcelerParcelable target,
83+
in ParcelerParcelable options,
84+
out ParcelableException exception
85+
);
86+
87+
void createHardLink(
88+
in ParcelerParcelable link,
89+
in ParcelerParcelable existing,
90+
out ParcelableException exception
91+
);
92+
93+
void delete(in ParcelerParcelable file, out ParcelableException exception);
94+
95+
boolean isSameFile(
96+
in ParcelerParcelable file1,
97+
in ParcelerParcelable file2,
98+
out ParcelableException exception
99+
);
100+
101+
void copy(
102+
in ParcelerParcelable source,
103+
in ParcelerParcelable target,
104+
in ParcelerParcelable options,
105+
out ParcelableException exception
106+
);
107+
108+
void move(
109+
in ParcelerParcelable source,
110+
in ParcelerParcelable target,
111+
in ParcelerParcelable options,
112+
out ParcelableException exception
113+
);
114+
115+
IRemotePosixFileStore openFileStore(
116+
in ParcelerParcelable file,
117+
out ParcelableException exception
118+
);
119+
120+
IRemoteFileWatcher openFileWatcher(out ParcelableException exception);
121+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.IRemoteFileSystem;
9+
10+
interface IRemoteFileSystemService {
11+
IRemoteFileSystem getFileSystem(String scheme);
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
import me.zhanghai.android.files.filesystem.remote.ParcelerParcelable;
10+
import me.zhanghai.android.files.filesystem.remote.IRemoteAsyncCloseableFlow;
11+
12+
interface IRemoteFileWatcher {
13+
IRemoteAsyncCloseableFlow watch(
14+
in ParcelerParcelable file,
15+
in ParcelerParcelable options,
16+
out ParcelableException exception
17+
);
18+
19+
void close(out ParcelableException exception);
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
import me.zhanghai.android.files.filesystem.remote.ParcelerParcelable;
10+
11+
interface IRemotePosixFileMetadataView {
12+
ParcelerParcelable readMetadata(out ParcelableException exception);
13+
14+
void setTimes(
15+
in ParcelerParcelable lastModificationTime,
16+
in ParcelerParcelable lastAccessTime,
17+
in ParcelerParcelable creationTime,
18+
out ParcelableException exception
19+
);
20+
21+
void setMode(in ParcelerParcelable mode, out ParcelableException exception);
22+
23+
void setOwnership(int userId, int groupId, out ParcelableException exception);
24+
25+
void setSeLinuxContext(in ParcelerParcelable context, out ParcelableException exception);
26+
27+
void restoreSeLinuxContext(out ParcelableException exception);
28+
29+
void close(out ParcelableException exception);
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
import me.zhanghai.android.files.filesystem.remote.ParcelerParcelable;
10+
11+
interface IRemotePosixFileStore {
12+
ParcelerParcelable readMetadata(out ParcelableException exception);
13+
14+
void setReadOnly(boolean readOnly, out ParcelableException exception);
15+
16+
void close(out ParcelableException exception);
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
10+
interface IRemoteRawAsyncSink {
11+
void write(in byte[] source, long byteCount, out ParcelableException exception);
12+
13+
void flush(out ParcelableException exception);
14+
15+
void close(out ParcelableException exception);
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2024 Hai Zhang <dreaming.in.code.zh@gmail.com>
3+
* All Rights Reserved.
4+
*/
5+
6+
package me.zhanghai.android.files.filesystem.remote;
7+
8+
import me.zhanghai.android.files.filesystem.remote.ParcelableException;
9+
10+
interface IRemoteRawAsyncSource {
11+
long readAtMostTo(out byte[] sink, long byteCount, out ParcelableException exception);
12+
13+
void close(out ParcelableException exception);
14+
}

0 commit comments

Comments
 (0)