Skip to content

Commit

Permalink
no java nio
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaodice committed Feb 18, 2024
1 parent 1253385 commit 723cd84
Show file tree
Hide file tree
Showing 95 changed files with 5,743 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mirai-console/backend/mirai-console/src/MiraiConsole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.console.util.SemVersion
import net.mamoe.mirai.utils.*
import java.io.File
import java.nio.file.Path
import com.llamalab.safs.Path
import java.time.Instant

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import net.mamoe.mirai.console.util.ConsoleInput
import net.mamoe.mirai.console.util.ConsoleInternalApi
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.*
import java.nio.file.Path
import com.llamalab.safs.Path
import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.annotation.AnnotationTarget.*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class AccessDeniedException extends FileSystemException {

public AccessDeniedException (String file) {
super(file);
}

public AccessDeniedException (String file, String otherFile, String reason) {
super(file, otherFile, reason);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class AtomicMoveNotSupportedException extends FileSystemException {

public AtomicMoveNotSupportedException (String source, String target, String reason) {
super(source, target, reason);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class ClosedFileSystemException extends IllegalStateException {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class ClosedWatchServiceException extends IllegalStateException {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

public interface CopyOption {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

import java.io.IOException;
import java.util.ConcurrentModificationException;

@SuppressWarnings("serial")
public class DirectoryIteratorException extends ConcurrentModificationException {

public DirectoryIteratorException (IOException cause) {
initCause(cause);
}

@Override
public final IOException getCause () {
return (IOException)super.getCause();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class DirectoryNotEmptyException extends FileSystemException {

public DirectoryNotEmptyException (String file) {
super(file);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

import java.io.Closeable;
import java.io.IOException;

public interface DirectoryStream<T> extends Iterable<T>, Closeable {
public interface Filter<T> {
public boolean accept (T entry) throws IOException;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class FileAlreadyExistsException extends FileSystemException {

public FileAlreadyExistsException (String file) {
super(file);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

import java.io.IOException;

public abstract class FileStore {
protected FileStore () {}
public abstract String name ();
public abstract String type ();
public abstract boolean isReadOnly ();
public abstract long getTotalSpace () throws IOException;
public abstract long getUsableSpace () throws IOException;
public abstract long getUnallocatedSpace () throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

import com.llamalab.safs.attribute.UserPrincipalLookupService;
import com.llamalab.safs.spi.FileSystemProvider;

import java.io.Closeable;
import java.io.IOException;
import java.util.Set;

public abstract class FileSystem implements Closeable {
public abstract FileSystemProvider provider ();
public abstract boolean isOpen ();
public abstract boolean isReadOnly ();
public abstract Set<String> supportedFileAttributeViews();
public abstract String getSeparator ();
public abstract Path getPath (String first, String... more);
public abstract PathMatcher getPathMatcher (String syntaxAndPattern);
public abstract Iterable<FileStore> getFileStores ();
public abstract Iterable<Path> getRootDirectories ();
public abstract UserPrincipalLookupService getUserPrincipalLookupService ();
public abstract WatchService newWatchService () throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2019 Henrik Lindqvist
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.llamalab.safs;

@SuppressWarnings("serial")
public class FileSystemAlreadyExistsException extends RuntimeException {

public FileSystemAlreadyExistsException () {}

public FileSystemAlreadyExistsException (String message) {
super(message);
}

}
Loading

0 comments on commit 723cd84

Please sign in to comment.