9 |
10 |
11 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/OpenOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public interface OpenOption {}
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/CopyOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public interface CopyOption {
20 | }
21 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/PathMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public interface PathMatcher {
20 | public boolean matches (Path path);
21 | }
22 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/GroupPrincipal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public interface GroupPrincipal extends UserPrincipal {
20 | }
21 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/AttributeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public interface AttributeView {
20 | public String name ();
21 | }
22 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/FileAttributeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public interface FileAttributeView extends AttributeView {
20 | }
21 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileVisitOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public enum FileVisitOption {
20 | /** Follow symbolic links. */
21 | FOLLOW_LINKS,
22 | }
23 |
--------------------------------------------------------------------------------
/safs-android-app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileVisitResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public enum FileVisitResult {
20 | CONTINUE,
21 | TERMINATE,
22 | SKIP_SUBTREE,
23 | SKIP_SIBLINGS,
24 | }
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/internal/FileType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.internal;
18 |
19 | public enum FileType {
20 | DIRECTORY,
21 | REGULAR_FILE,
22 | SYMBOLIC_LINK,
23 | OTHER,
24 | }
25 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/ClosedFileSystemException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class ClosedFileSystemException extends IllegalStateException {
21 | }
22 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/ClosedWatchServiceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class ClosedWatchServiceException extends IllegalStateException {}
21 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/FileAttribute.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public interface FileAttribute {
20 | public String name ();
21 | public T value ();
22 | }
23 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/UserPrincipal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.security.Principal;
20 |
21 | public interface UserPrincipal extends Principal {
22 | }
23 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/LinkOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public enum LinkOption implements OpenOption, CopyOption {
20 | /** Do not follow symbolic links. */
21 | NOFOLLOW_LINKS,
22 | }
23 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/ReadOnlyFileSystemException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class ReadOnlyFileSystemException extends UnsupportedOperationException {
21 | }
22 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/StandardCopyOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public enum StandardCopyOption implements CopyOption {
20 | REPLACE_EXISTING,
21 | COPY_ATTRIBUTES,
22 | ATOMIC_MOVE,
23 | }
24 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/internal/DefaultFileSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.internal;
18 |
19 | import com.llamalab.safs.Path;
20 |
21 | public interface DefaultFileSystem {
22 | public Path getCacheDirectory ();
23 | }
24 |
--------------------------------------------------------------------------------
/safs-core/README.md:
--------------------------------------------------------------------------------
1 | safs-core
2 | =========
3 |
4 | [](https://bintray.com/hlindqvi/safs/safs/_latestVersion)
5 |
6 | The core package use the [java.io.File](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) to access the file-system.
7 | Only support OS'es using `/` as path separator, e.g. Unix/Linux.
8 |
9 | ### Getting started
10 | Add to Gradle project `dependencies`:
11 | ```groovy
12 | implementation 'com.llamalab.safs:safs-core:0.2.0'
13 | ```
14 |
15 | ### Usage
16 | Same as [java.nio.file](https://docs.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html) packages except located in `com.llamalab.safs`,
17 | and instead of [java.nio.channels.SeekableByteChannel](https://docs.oracle.com/javase/7/docs/api/java/nio/channels/SeekableByteChannel.html)
18 | use `com.llamalab.safs.channels.SeekableByteChannel`.
19 |
--------------------------------------------------------------------------------
/safs-android-app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/NoSuchFileException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class NoSuchFileException extends FileSystemException {
21 |
22 | public NoSuchFileException (String file) {
23 | super(file);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/bintray.gradle:
--------------------------------------------------------------------------------
1 |
2 | Properties localProperties = new Properties()
3 | localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
4 |
5 | bintray {
6 | user = localProperties.getProperty('bintray.user')
7 | key = localProperties.getProperty('bintray.key')
8 | publications = [ 'maven' ]
9 | dryRun = false
10 | publish = false
11 | override = false
12 | pkg {
13 | repo = 'safs'
14 | name = 'safs'
15 | licenses = [ 'Apache-2.0' ]
16 | vcsUrl = 'https://github.com/henrik-lindqvist/safs.git'
17 | issueTrackerUrl = 'https://github.com/henrik-lindqvist/safs/issues'
18 | websiteUrl = 'https://github.com/henrik-lindqvist/safs'
19 | version {
20 | name = rootProject.ext.releaseVersion
21 | //vcsTag = rootProject.ext.releaseVersion
22 | gpg {
23 | passphrase = localProperties.getProperty('bintray.gpg.passphrase')
24 | sign = true
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/NotDirectoryException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class NotDirectoryException extends FileSystemException {
21 |
22 | public NotDirectoryException (String file) {
23 | super(file);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileSystemLoopException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class FileSystemLoopException extends FileSystemException {
21 |
22 | public FileSystemLoopException (String file) {
23 | super(file);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/DirectoryNotEmptyException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class DirectoryNotEmptyException extends FileSystemException {
21 |
22 | public DirectoryNotEmptyException (String file) {
23 | super(file);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileAlreadyExistsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class FileAlreadyExistsException extends FileSystemException {
21 |
22 | public FileAlreadyExistsException (String file) {
23 | super(file);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: 'maven-publish'
3 | apply plugin: 'com.jfrog.bintray'
4 | apply from: '../bintray.gradle'
5 |
6 | // Support Java 6 which lack java.nio.file:
7 | //noinspection GroovyUnusedAssignment
8 | sourceCompatibility = 1.6
9 | //noinspection GroovyUnusedAssignment
10 | targetCompatibility = 1.6
11 |
12 | dependencies {
13 | implementation fileTree(dir: 'libs', include: ['*.jar'])
14 | testImplementation 'junit:junit:4.12'
15 | }
16 |
17 | publishing {
18 | publications {
19 | maven(MavenPublication) {
20 | groupId = 'com.llamalab.safs'
21 | artifactId = 'safs-core'
22 | version = rootProject.ext.releaseVersion
23 | from components.java
24 | artifact sourcesJar // required by jcentral
25 | }
26 | }
27 | }
28 |
29 | task sourcesJar (type: Jar, dependsOn: classes) {
30 | from sourceSets.main.allSource
31 | classifier = 'sources'
32 | }
33 |
34 | artifacts {
35 | archives sourcesJar
36 | }
37 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/WatchKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.util.List;
20 |
21 | public interface WatchKey {
22 | public Watchable watchable ();
23 | public boolean isValid ();
24 | public boolean reset ();
25 | public void cancel ();
26 | public List> pollEvents ();
27 | }
28 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/DirectoryStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.io.Closeable;
20 | import java.io.IOException;
21 |
22 | public interface DirectoryStream extends Iterable, Closeable {
23 | public interface Filter {
24 | public boolean accept (T entry) throws IOException;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/PosixFilePermission.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public enum PosixFilePermission {
20 | OWNER_READ,
21 | OWNER_WRITE,
22 | OWNER_EXECUTE,
23 | GROUP_READ,
24 | GROUP_WRITE,
25 | GROUP_EXECUTE,
26 | OTHERS_READ,
27 | OTHERS_WRITE,
28 | OTHERS_EXECUTE
29 | }
30 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/StandardOpenOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public enum StandardOpenOption implements OpenOption {
20 | READ,
21 | WRITE,
22 | APPEND,
23 | TRUNCATE_EXISTING,
24 | CREATE,
25 | CREATE_NEW,
26 | /** Unsupported. */
27 | DELETE_ON_CLOSE,
28 | SPARSE,
29 | SYNC,
30 | DSYNC,
31 | }
32 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/PosixFileAttributes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.util.Set;
20 |
21 | public interface PosixFileAttributes extends BasicFileAttributes {
22 | public GroupPrincipal group ();
23 | public UserPrincipal owner ();
24 | public Set permissions ();
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/ProviderMismatchException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class ProviderMismatchException extends IllegalArgumentException {
21 |
22 | public ProviderMismatchException () {}
23 |
24 | public ProviderMismatchException (String message) {
25 | super(message);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/ProviderNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class ProviderNotFoundException extends RuntimeException {
21 |
22 | public ProviderNotFoundException () {}
23 |
24 | public ProviderNotFoundException (String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/FileOwnerAttributeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.io.IOException;
20 |
21 | public interface FileOwnerAttributeView extends FileAttributeView {
22 | public UserPrincipal getOwner () throws IOException;
23 | public void setOwner (UserPrincipal owner) throws IOException;
24 | }
25 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/AtomicMoveNotSupportedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class AtomicMoveNotSupportedException extends FileSystemException {
21 |
22 | public AtomicMoveNotSupportedException (String source, String target, String reason) {
23 | super(source, target, reason);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileSystemNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class FileSystemNotFoundException extends RuntimeException {
21 |
22 | public FileSystemNotFoundException () {}
23 |
24 | public FileSystemNotFoundException (String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/safs-android/src/main/java/com/llamalab/safs/android/FileStoreNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.android;
18 |
19 | import com.llamalab.safs.FileSystemException;
20 |
21 | @SuppressWarnings("serial")
22 | public class FileStoreNotFoundException extends FileSystemException {
23 |
24 | public FileStoreNotFoundException (String volume) {
25 | super(volume);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileSystemAlreadyExistsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class FileSystemAlreadyExistsException extends RuntimeException {
21 |
22 | public FileSystemAlreadyExistsException () {}
23 |
24 | public FileSystemAlreadyExistsException (String message) {
25 | super(message);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/Watchable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.io.IOException;
20 |
21 | public interface Watchable {
22 | public WatchKey register (WatchService service, WatchEvent.Kind>[] kinds, WatchEvent.Modifier... modifiers) throws IOException;
23 | public WatchKey register (WatchService service, WatchEvent.Kind>... kinds) throws IOException;
24 | }
25 |
--------------------------------------------------------------------------------
/safs-android/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | -keep class com.llamalab.safs.spi.FileSystemProvider { *; }
24 | -keep class * extends com.llamalab.safs.spi.FileSystemProvider { *; }
25 | -keep class * extends com.llamalab.safs.spi.FileTypeDetector { *; }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/WatchService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.io.Closeable;
20 | import java.util.concurrent.TimeUnit;
21 |
22 | public interface WatchService extends Closeable {
23 | public WatchKey poll ();
24 | public WatchKey poll (long timeout, TimeUnit unit) throws InterruptedException;
25 | public WatchKey take () throws InterruptedException;
26 | }
27 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/NotLinkException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class NotLinkException extends FileSystemException {
21 |
22 | public NotLinkException (String file) {
23 | super(file);
24 | }
25 |
26 | public NotLinkException (String file, String otherFile, String reason) {
27 | super(file, otherFile, reason);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/BasicFileAttributeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.io.IOException;
20 |
21 | public interface BasicFileAttributeView extends FileAttributeView {
22 | public BasicFileAttributes readAttributes () throws IOException;
23 | public void setTimes (FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime) throws IOException;
24 | }
25 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/AccessDeniedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | @SuppressWarnings("serial")
20 | public class AccessDeniedException extends FileSystemException {
21 |
22 | public AccessDeniedException (String file) {
23 | super(file);
24 | }
25 |
26 | public AccessDeniedException (String file, String otherFile, String reason) {
27 | super(file, otherFile, reason);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/WatchEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | public interface WatchEvent {
20 |
21 | public static interface Kind {
22 | public String name ();
23 | public Class type ();
24 | }
25 |
26 | public static interface Modifier {
27 | public String name ();
28 | }
29 |
30 | public Kind kind ();
31 | public T context ();
32 | public int count ();
33 | }
34 |
--------------------------------------------------------------------------------
/safs-android/src/main/java/com/llamalab/safs/android/AndroidOpenOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.android;
18 |
19 | import com.llamalab.safs.OpenOption;
20 |
21 | public enum AndroidOpenOption implements OpenOption {
22 | /**
23 | * Bypass document check for a minor performance improvement. Use if the file is known to be
24 | * located in internal (private app) storage or primary external storage.
25 | */
26 | NODOCUMENT,
27 | }
28 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/PosixFileAttributeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.io.IOException;
20 | import java.util.Set;
21 |
22 | public interface PosixFileAttributeView extends BasicFileAttributeView, FileOwnerAttributeView {
23 | public void setGroup (GroupPrincipal group) throws IOException;
24 | public void setPermissions (Set perms) throws IOException;
25 | }
26 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/UserPrincipalNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.io.IOException;
20 |
21 | public class UserPrincipalNotFoundException extends IOException {
22 |
23 | private final String name;
24 |
25 | public UserPrincipalNotFoundException (String name) {
26 | this.name = name;
27 | }
28 |
29 | public String getName (){
30 | return name;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/spi/FileTypeDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.spi;
18 |
19 | import com.llamalab.safs.Path;
20 |
21 | import java.io.IOException;
22 |
23 | /**
24 | * System.setProperty("content.types.user.table", "/path/to/property/file");
25 | */
26 | public abstract class FileTypeDetector {
27 |
28 | protected FileTypeDetector () {}
29 |
30 | public abstract String probeContentType (Path path) throws IOException;
31 | }
32 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/UserPrincipalLookupService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | import java.io.IOException;
20 |
21 | public abstract class UserPrincipalLookupService {
22 |
23 | protected UserPrincipalLookupService () {}
24 |
25 | public abstract UserPrincipal lookupPrincipalByName (String name) throws IOException;
26 | public abstract GroupPrincipal lookupPrincipalByGroupName (String group) throws IOException;
27 | }
28 |
--------------------------------------------------------------------------------
/safs-android/src/main/java/com/llamalab/safs/android/NotDocumentUriException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.android;
18 |
19 | import android.net.Uri;
20 |
21 | @SuppressWarnings("serial")
22 | public class NotDocumentUriException extends IllegalArgumentException {
23 |
24 | private final Uri uri;
25 |
26 | public NotDocumentUriException (Uri uri) {
27 | super(uri.toString());
28 | this.uri = uri;
29 | }
30 |
31 | public Uri getUri () {
32 | return uri;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/attributes/BasicFileAttributes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.attributes;
18 |
19 | public interface BasicFileAttributes {
20 | public Object fileKey ();
21 | public boolean isDirectory ();
22 | public boolean isOther ();
23 | public boolean isRegularFile ();
24 | public boolean isSymbolicLink ();
25 | public long size ();
26 | public FileTime creationTime ();
27 | public FileTime lastModifiedTime ();
28 | public FileTime lastAccessTime ();
29 | }
30 |
--------------------------------------------------------------------------------
/safs-android/src/main/java/com/llamalab/safs/android/AndroidWatchEventKind.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.android;
18 |
19 | import com.llamalab.safs.internal.WatchEventKind;
20 |
21 | final class AndroidWatchEventKind extends WatchEventKind {
22 |
23 | private final int event;
24 |
25 | public AndroidWatchEventKind (String name, Class type, int event) {
26 | super(name, type);
27 | this.event = event;
28 | }
29 |
30 | public final int event () {
31 | return event;
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/channels/SeekableByteChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.channels;
18 |
19 | import java.io.IOException;
20 | import java.nio.channels.ByteChannel;
21 |
22 | public interface SeekableByteChannel extends ByteChannel {
23 | public long position () throws IOException;
24 | public SeekableByteChannel position (long newPosition) throws IOException;
25 | public long size () throws IOException;
26 | public SeekableByteChannel truncate (long size) throws IOException;
27 | }
28 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.io.IOException;
20 |
21 | public abstract class FileStore {
22 | protected FileStore () {}
23 | public abstract String name ();
24 | public abstract String type ();
25 | public abstract boolean isReadOnly ();
26 | public abstract long getTotalSpace () throws IOException;
27 | public abstract long getUsableSpace () throws IOException;
28 | public abstract long getUnallocatedSpace () throws IOException;
29 | }
30 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/DirectoryIteratorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import java.io.IOException;
20 | import java.util.ConcurrentModificationException;
21 |
22 | @SuppressWarnings("serial")
23 | public class DirectoryIteratorException extends ConcurrentModificationException {
24 |
25 | public DirectoryIteratorException (IOException cause) {
26 | initCause(cause);
27 | }
28 |
29 | @Override
30 | public final IOException getCause () {
31 | return (IOException)super.getCause();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/FileVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import com.llamalab.safs.attributes.BasicFileAttributes;
20 |
21 | import java.io.IOException;
22 |
23 | public interface FileVisitor {
24 | public FileVisitResult preVisitDirectory (T dir, BasicFileAttributes attrs) throws IOException;
25 | public FileVisitResult postVisitDirectory (T dir, IOException e) throws IOException;
26 | public FileVisitResult visitFile (T file, BasicFileAttributes attrs) throws IOException;
27 | public FileVisitResult visitFileFailed (T file, IOException e) throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/safs-android-app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId 'com.llamalab.safs.android.app'
7 | minSdkVersion 14
8 | //noinspection OldTargetApi
9 | targetSdkVersion 26
10 | versionCode 2
11 | versionName rootProject.ext.releaseVersion
12 |
13 | buildConfigField 'int', 'TARGET_SDK_INT', targetSdkVersion.apiLevel.toString()
14 |
15 | //testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
16 | }
17 | compileOptions {
18 | sourceCompatibility JavaVersion.VERSION_1_7
19 | targetCompatibility JavaVersion.VERSION_1_7
20 | }
21 | buildTypes {
22 | release {
23 | //minifyEnabled false
24 | //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 | implementation project(':safs-android')
32 | implementation 'com.android.support:support-v13:27.1.1'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 | //androidTestImplementation 'com.android.support.test:rules:1.0.2'
36 | //androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
37 | }
38 |
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/internal/WatchEventKind.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs.internal;
18 |
19 | import com.llamalab.safs.WatchEvent;
20 |
21 | public class WatchEventKind implements WatchEvent.Kind {
22 |
23 | private final String name;
24 | private final Class type;
25 |
26 | public WatchEventKind (String name, Class type) {
27 | this.name = name;
28 | this.type = type;
29 | }
30 |
31 | @Override
32 | public final String name () {
33 | return name;
34 | }
35 |
36 | @Override
37 | public final Class type () {
38 | return type;
39 | }
40 |
41 | @Override
42 | public final String toString () {
43 | return name;
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/safs-core/src/main/java/com/llamalab/safs/StandardWatchEventKinds.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Henrik Lindqvist
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.llamalab.safs;
18 |
19 | import com.llamalab.safs.internal.WatchEventKind;
20 |
21 | public final class StandardWatchEventKinds {
22 |
23 | public static final WatchEvent.Kind