Easter cleaning
This commit is contained in:
commit
9e36078b2e
1862 changed files with 270281 additions and 0 deletions
|
|
@ -0,0 +1,387 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import love.distributedrebirth.nx01.redsea.hyper.HyperFileSystem;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveCommand;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveInfo;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveResult;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveTouch;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperBeeEntry;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperBeeHive;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperFlower;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperFlowerAnther;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperFlowerBeeFly;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperFlowerBeeFormation;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperLint;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperLintSlime;
|
||||
import love.distributedrebirth.nx01.warp.fault.BassFaultAnchor;
|
||||
import love.distributedrebirth.nx01.warp.fault.FaultBeanInterrupted;
|
||||
import love.distributedrebirth.nx01.warp.fault.FaultStreamDelegate;
|
||||
import love.distributedrebirth.nx01.warp.fault.FaultStreamInterrupted;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class HyperLocalFileSystem implements HyperFileSystem {
|
||||
|
||||
// npm i -g drives
|
||||
|
||||
// TODO-1: replace with java dat version
|
||||
// TODO-2: write UDP react warp script
|
||||
// TODO-3: defined datV3? for octals
|
||||
// TODO-4: defined structs+code impl in xml for nether DB + orisis VHDL support
|
||||
// TODO-5: Export octal datX code to every computer language
|
||||
|
||||
private final String localStoragePath;
|
||||
private final String localMirrorPath;
|
||||
|
||||
public HyperLocalFileSystem() {
|
||||
this(null, ".drives/localdir/"); // we ALWAYS run in user.home
|
||||
}
|
||||
|
||||
public HyperLocalFileSystem(String localStoragePath, String localMirrorPath) {
|
||||
this.localStoragePath = localStoragePath;
|
||||
this.localMirrorPath = Objects.requireNonNull(localMirrorPath);
|
||||
}
|
||||
|
||||
|
||||
private Consumer<Map<String, String>> buildTracer(HyperBeeHive hive) {
|
||||
return buildTracer(hive, null);
|
||||
}
|
||||
|
||||
private Consumer<Map<String, String>> buildTracer(HyperBeeHive hive, HyperLint lint) {
|
||||
Consumer<Map<String, String>> tracer = v -> {
|
||||
v.put("jdat-local-mirror-path", localMirrorPath);
|
||||
if (localStoragePath != null) {
|
||||
v.put("jdat-local-storage-path", localStoragePath);
|
||||
}
|
||||
v.put("hyper-bee-hive-key", hive.getKey());
|
||||
if (lint != null) {
|
||||
v.put("hyper-lint-snail", lint.getSnail());
|
||||
}
|
||||
};
|
||||
return tracer;
|
||||
}
|
||||
|
||||
private void localMirrorRead(HyperBeeHive hive) {
|
||||
try {
|
||||
File localHivePath = Path.of(System.getProperty("user.home"), localMirrorPath, hive.getKey()).toFile();
|
||||
if (!localHivePath.exists()) {
|
||||
localHivePath.mkdirs();
|
||||
}
|
||||
System.out.println("mirror read path: " + localHivePath.getAbsolutePath());
|
||||
HyperLocalDriveResult res = cmdMirror(hive.getKey(), localHivePath.getAbsolutePath());
|
||||
System.out.println("mirror read result: " + res.getResult());
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive));
|
||||
}
|
||||
}
|
||||
|
||||
private void localMirrorWrite(HyperBeeHive hive) {
|
||||
try {
|
||||
File localHivePath = Path.of(System.getProperty("user.home"), localMirrorPath, hive.getKey()).toFile();
|
||||
System.out.println("mirror write path: " + localHivePath);
|
||||
HyperLocalDriveResult res = cmdMirror(localHivePath.getAbsolutePath(), hive.getKey());
|
||||
System.out.println("mirror write result: " + res.getResult());
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyperFlower eden(HyperBeeHive hive) {
|
||||
localMirrorRead(hive);
|
||||
try {
|
||||
return cmdList(hive.getKey(), null, false);
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyperFlower flower(HyperBeeHive hive, HyperLintSlime slime) {
|
||||
localMirrorRead(hive);
|
||||
try {
|
||||
return cmdList(hive.getKey(), slime.getSnail(), false);
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive, slime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyperFlower garden(HyperBeeHive hive, HyperLintSlime slime) {
|
||||
localMirrorRead(hive);
|
||||
try {
|
||||
return cmdList(hive.getKey(), slime.getSnail(), true);
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive, slime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HyperBeeEntry> entry(HyperBeeHive hive, HyperLint lint) {
|
||||
localMirrorRead(hive);
|
||||
HyperLocalDriveResult res;
|
||||
try {
|
||||
res = cmdEntry(hive.getKey(), lint.getSnail());
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive, lint));
|
||||
}
|
||||
if (res.getResult().isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Long seq = null;
|
||||
String name = null;
|
||||
for (String line : res.getResult().split("\n")) {
|
||||
if (line.startsWith("Sequence")) {
|
||||
String seqRaw = line.substring(line.indexOf(' ') + 1, line.length());
|
||||
seq = Long.parseLong(seqRaw);
|
||||
}
|
||||
if (line.startsWith("Key")) {
|
||||
name = line.substring(line.indexOf(' ') + 1, line.length());
|
||||
}
|
||||
}
|
||||
return Optional.of(new HyperBeeEntry(seq, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer get(HyperBeeHive hive, HyperLint lint) {
|
||||
localMirrorRead(hive);
|
||||
try {
|
||||
Path localSnailPath = Path.of(System.getProperty("user.home"), localMirrorPath, hive.getKey(), lint.getSnail());
|
||||
return ByteBuffer.wrap(Files.readAllBytes(localSnailPath));
|
||||
} catch (IOException e) {
|
||||
throw new FaultStreamInterrupted(e, getClass(), buildTracer(hive, lint));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(HyperBeeHive hive, HyperLint lint, ByteBuffer blob) {
|
||||
localMirrorRead(hive);
|
||||
try {
|
||||
Path localSnailPath = Path.of(System.getProperty("user.home"), localMirrorPath, hive.getKey(), lint.getSnail());
|
||||
localSnailPath.toFile().getParentFile().mkdirs();
|
||||
Files.write(localSnailPath, blob.array());
|
||||
} catch (IOException e) {
|
||||
throw new FaultStreamInterrupted(e, getClass(), buildTracer(hive, lint));
|
||||
}
|
||||
localMirrorWrite(hive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long rm(HyperBeeHive hive, HyperLintSlime slime) {
|
||||
long result = 1; // TODO impl remove count
|
||||
try {
|
||||
cmdRemove(hive.getKey(), slime.getSnail());
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(getClass(), buildTracer(hive, slime));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// =========== Local
|
||||
|
||||
public HyperLocalDriveResult cmdInit() throws IOException, InterruptedException {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.INIT);
|
||||
}
|
||||
|
||||
public HyperLocalDriveTouch cmdTouch() throws IOException, InterruptedException {
|
||||
return new HyperLocalDriveTouch(executeHyperdrive(HyperLocalDriveCommand.TOUCH));
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdMirror(String src, String dst) {
|
||||
return cmdMirror(src, dst, false);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdMirror(String src, String dst, boolean dryRun) {
|
||||
String argDryRun = null;
|
||||
if (dryRun) {
|
||||
argDryRun = "--dry-run";
|
||||
}
|
||||
return executeHyperdrive(HyperLocalDriveCommand.MIRROR, argDryRun, src, dst);
|
||||
}
|
||||
|
||||
public HyperFlower cmdList(String driveKey, String snail, boolean deepGarden) {
|
||||
String deeper = null;
|
||||
if (deepGarden) {
|
||||
deeper = "-r";
|
||||
}
|
||||
HyperLocalDriveResult res = executeHyperdrive(HyperLocalDriveCommand.LS, deeper, driveKey, snail);
|
||||
//System.out.println("\n\nRES:\n"+res.getResult());
|
||||
Set<String> folders = new LinkedHashSet<>();
|
||||
List<HyperFlowerAnther> flies = new ArrayList<>();
|
||||
for (String line : res.getResult().split("\n")) {
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
int spaceIdx = line.indexOf(' ');
|
||||
if (spaceIdx == -1) {
|
||||
if (line.startsWith("/")) {
|
||||
flies.add(new HyperFlowerBeeFormation(line));
|
||||
} else { // TODO: TMP add slash + snail until upstream is fixed.
|
||||
flies.add(new HyperFlowerBeeFormation("/" + snail + "/" + line));
|
||||
}
|
||||
folders.add(line);
|
||||
continue;
|
||||
}
|
||||
String name = line.substring(0, spaceIdx);
|
||||
String sizeRaw = line.substring(line.indexOf('('), line.indexOf(')'));
|
||||
sizeRaw = sizeRaw
|
||||
.codePoints()
|
||||
.filter(v -> Character.isDigit(v))
|
||||
.mapToObj(v -> new StringBuilder().appendCodePoint(v))
|
||||
.collect(Collectors.joining());
|
||||
Long size = Long.parseLong(sizeRaw);
|
||||
flies.add(new HyperFlowerBeeFly(name, size));
|
||||
|
||||
// TODO: -r has no folders, TMP delete after upstream issue is fixed
|
||||
int folderIdx = name.lastIndexOf('/');
|
||||
if (folderIdx > 0) {
|
||||
String folder = name.substring(0, folderIdx);
|
||||
if (!folders.contains(folder)) {
|
||||
folders.add(folder);
|
||||
flies.add(new HyperFlowerBeeFormation(folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HyperFlower(flies);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdSeed(String driveKey) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.SEED, driveKey);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdDownload(String driveKey) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.DOWNLOAD, driveKey);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdServe(String driveKey) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.SERVE, driveKey);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdEntry(String driveKey, String path) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.ENTRY, driveKey, path);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdGet(String driveKey, String path) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.GET, driveKey, path);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdPut(String driveKey, String path, String blob) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.PUT, driveKey, path, blob);
|
||||
}
|
||||
|
||||
public HyperLocalDriveInfo cmdInfo(String driveKey) {
|
||||
return new HyperLocalDriveInfo(executeHyperdrive(HyperLocalDriveCommand.INFO, driveKey));
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdPurge(String driveKey) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.PURGE, driveKey);
|
||||
}
|
||||
|
||||
public HyperLocalDriveResult cmdRemove(String driveKey, String path) {
|
||||
return executeHyperdrive(HyperLocalDriveCommand.RM, driveKey, path);
|
||||
}
|
||||
|
||||
private HyperLocalDriveResult executeHyperdrive(HyperLocalDriveCommand cmd, String...args) {
|
||||
List<String> cmdArgs = new ArrayList<>();
|
||||
cmdArgs.add("drives");
|
||||
cmdArgs.add(cmd.getQName());
|
||||
if (localStoragePath != null && !HyperLocalDriveCommand.INIT.equals(cmd)) {
|
||||
cmdArgs.add("--storage");
|
||||
cmdArgs.add(localStoragePath);
|
||||
}
|
||||
for (String arg : args) {
|
||||
if (arg == null) {
|
||||
continue;
|
||||
}
|
||||
cmdArgs.add(arg);
|
||||
}
|
||||
Consumer<Map<String, String>> tracer = v -> v.put("Hyper-Drives-Command", cmdArgs.stream().collect(Collectors.joining(" ")));
|
||||
ProcessBuilder builder = new ProcessBuilder();
|
||||
builder.command(cmdArgs);
|
||||
builder.directory(new File(System.getProperty("user.home")));
|
||||
builder.redirectErrorStream(true);
|
||||
try {
|
||||
Process process = builder.start();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
try(BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
buf.append(line);
|
||||
buf.append('\n');
|
||||
}
|
||||
}
|
||||
if (buf.length() > 0) {
|
||||
buf.deleteCharAt(buf.length()-1);
|
||||
}
|
||||
int exitCode = process.waitFor();
|
||||
String result = buf.toString();
|
||||
String storagePath = result;
|
||||
int storagePathIdxStart = buf.indexOf("Storage:");
|
||||
if (storagePathIdxStart >= 0) {
|
||||
int storagePathIdxEnd = buf.indexOf("\n", storagePathIdxStart);
|
||||
if (storagePathIdxEnd > 0) {
|
||||
storagePath = buf.substring(storagePathIdxStart, storagePathIdxEnd);
|
||||
result = buf.substring(storagePathIdxEnd + 1);
|
||||
}
|
||||
}
|
||||
if (exitCode > 0) {
|
||||
//System.out.println("error:....");
|
||||
//System.out.println(result);
|
||||
//System.out.println("");
|
||||
throw FaultStreamDelegate.valueOfDuckTail(getClass(), "js", result).withSignalTrace(getClass(), v -> {
|
||||
v.put("Hyper-Drives-Exit-Code", Integer.toString(exitCode));
|
||||
tracer.accept(v);
|
||||
});
|
||||
}
|
||||
return new HyperLocalDriveResult(storagePath, result);
|
||||
} catch (IOException e) {
|
||||
throw new FaultStreamInterrupted(e, getClass(), tracer);
|
||||
} catch (InterruptedException e) {
|
||||
throw new FaultBeanInterrupted(e, getClass(), tracer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local.drive;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public enum HyperLocalDriveCommand {
|
||||
INIT,
|
||||
TOUCH,
|
||||
MIRROR,
|
||||
LS,
|
||||
SEED,
|
||||
DOWNLOAD,
|
||||
SERVE,
|
||||
PUT,
|
||||
ENTRY,
|
||||
GET,
|
||||
RM,
|
||||
INFO,
|
||||
PURGE,
|
||||
;
|
||||
|
||||
private final String qName;
|
||||
|
||||
private HyperLocalDriveCommand() {
|
||||
this.qName = name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getQName() {
|
||||
return qName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local.drive;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public final class HyperLocalDriveInfo extends HyperLocalDriveResult {
|
||||
|
||||
private final Map<HyperLocalDriveInfoLine, String> driveInfo = new HashMap<>();
|
||||
|
||||
public HyperLocalDriveInfo(HyperLocalDriveResult cmd) {
|
||||
super(cmd.getStoragePath(), cmd.getResult());
|
||||
List<String> data = Arrays.asList(cmd.getResult().split("\n"));
|
||||
for (int i=0;i<data.size();i++) {
|
||||
String line = data.get(i);
|
||||
for (HyperLocalDriveInfoLine infoType : HyperLocalDriveInfoLine.values()) {
|
||||
if (line.startsWith(infoType.getSplitPrefix())) {
|
||||
String value = line.substring(infoType.getSplitPrefix().length(), line.length());
|
||||
driveInfo.put(infoType, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getDriveInfo(HyperLocalDriveInfoLine infoType) {
|
||||
return driveInfo.get(infoType);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local.drive;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public enum HyperLocalDriveInfoLine {
|
||||
KEY("Key: "),
|
||||
CONTENT_KEY("Content key: "),
|
||||
VERSION("Version: "),
|
||||
WRITABLE("Writable? "),
|
||||
FILES_CORE_LENGTH("Files core length: "),
|
||||
BLOBS_CORE_LENGTH("Blobs core length: "),
|
||||
DRIVE_SIZE("Drive size: "),
|
||||
;
|
||||
|
||||
private final String splitPrefix;
|
||||
|
||||
private HyperLocalDriveInfoLine(String splitPrefix) {
|
||||
this.splitPrefix = splitPrefix;
|
||||
}
|
||||
|
||||
public String getSplitPrefix() {
|
||||
return splitPrefix;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local.drive;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class HyperLocalDriveResult {
|
||||
|
||||
private final String storagePath;
|
||||
private final String result;
|
||||
|
||||
public HyperLocalDriveResult(String storagePath, String result) {
|
||||
this.storagePath = storagePath;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getStoragePath() {
|
||||
return storagePath;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local.drive;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public final class HyperLocalDriveTouch extends HyperLocalDriveResult {
|
||||
|
||||
private final String driveId;
|
||||
|
||||
public HyperLocalDriveTouch(HyperLocalDriveResult cmd) {
|
||||
super(cmd.getStoragePath(), cmd.getResult());
|
||||
driveId = cmd.getResult().split("drive: ")[1];
|
||||
}
|
||||
|
||||
public String getDriveId() {
|
||||
return driveId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.redsea.hyper.local;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperBeeHive;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperFlower;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.model.HyperLint;
|
||||
import love.distributedrebirth.nx01.warp.fault.BassFaultAnchor;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveInfo;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveInfoLine;
|
||||
import love.distributedrebirth.nx01.redsea.hyper.local.drive.HyperLocalDriveTouch;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class HyperLocalFileSystemTest {
|
||||
|
||||
@Test
|
||||
public void testFail() throws IOException, InterruptedException {
|
||||
HyperLocalFileSystem datfs = new HyperLocalFileSystem();
|
||||
try {
|
||||
datfs.cmdList("", "", true);
|
||||
} catch (Exception e) {
|
||||
if (BassFaultAnchor.class.isAssignableFrom(e.getClass())) {
|
||||
//System.err.println(BassFaultAnchor.class.cast(e).toStringZilLaLa());
|
||||
}
|
||||
//throw e;
|
||||
}
|
||||
//ERR: datfs.cmdList("0000000000000000000000000000000000000000000000000000");
|
||||
//Assertions.assertTrue(datfs.cmdInfo("").isError()); // ERR
|
||||
//Assertions.assertTrue(datfs.cmdInfo("0").isError()); // ERR
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testMirrorFail() throws IOException, InterruptedException {
|
||||
// HyperLocalFileSystem datfs = new HyperLocalFileSystem();
|
||||
// String driveId = datfs.cmdTouch().getDriveId();
|
||||
// datfs.cmdPut(driveId, "boom/junit.txt", "junit");
|
||||
// datfs.cmdPut(driveId, "boom", "foo");
|
||||
// datfs.cmdMirror(driveId, Files.createTempDirectory("mirrorFail").toString());
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testBasic() throws IOException, InterruptedException {
|
||||
HyperLocalFileSystem datfs = new HyperLocalFileSystem();
|
||||
HyperLocalDriveTouch touchResult = datfs.cmdTouch();
|
||||
Assertions.assertNotNull(touchResult);
|
||||
Assertions.assertNotNull(touchResult.getResult());
|
||||
Assertions.assertNotNull(touchResult.getDriveId());
|
||||
String driveId = touchResult.getDriveId();
|
||||
Assertions.assertFalse(driveId.contains(" "));
|
||||
Assertions.assertFalse(driveId.contains(":"));
|
||||
|
||||
datfs.cmdPut(driveId, "junit-root.txt", "junit");
|
||||
datfs.cmdPut(driveId, "test/junit1.txt", "foo");
|
||||
datfs.cmdPut(driveId, "test/junit2.txt", "bar");
|
||||
|
||||
HyperBeeHive hive = new HyperBeeHive(touchResult.getDriveId());
|
||||
datfs.put(hive, hive.createHyperLint("junit-root2.txt"), ByteBuffer.wrap("test".getBytes()));
|
||||
|
||||
HyperFlower listResult = datfs.cmdList(driveId, null, true);
|
||||
Assertions.assertNotNull(listResult);
|
||||
Assertions.assertNotNull(listResult.getAnthers());
|
||||
Assertions.assertEquals(5, listResult.getAnthers().size());
|
||||
Assertions.assertEquals(4, listResult.getBeeFlies().size());
|
||||
Assertions.assertEquals(1, listResult.getBeeFormations().size());
|
||||
Assertions.assertEquals("junit", datfs.cmdGet(driveId, "junit-root.txt").getResult());
|
||||
|
||||
datfs.cmdPurge(driveId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnicode() throws IOException, InterruptedException {
|
||||
HyperLocalFileSystem datfs = new HyperLocalFileSystem();
|
||||
HyperLocalDriveTouch touchResult = datfs.cmdTouch();
|
||||
Assertions.assertNotNull(touchResult);
|
||||
String driveId = touchResult.getDriveId();
|
||||
|
||||
datfs.cmdPut(driveId, "仙上主天.txt", "仙上主天");
|
||||
datfs.cmdPut(driveId, "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕.txt", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
|
||||
datfs.cmdPut(driveId, "ᒡᒢᑊᒻᒻᓫᔿ.txt", "ᒡᒢᑊᒻᒻᓫᔿ");
|
||||
datfs.cmdPut(driveId, "יֽ֕זְ֔/זֲ֟דֲ֩יֳ֟ײֳ֔יֳ֞וֶ֕זֵ֟ױֳ֩רְ֠װֶ֔רְ֠װֶ֔װֽ֕רֶ֔יֽ֔יֽ֔װֶ֕וְ֕ײֵ֔וֲ֩", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕ᒡᒢᑊᒻᒻᓫᔿ仙上主天");
|
||||
|
||||
HyperFlower listResult = datfs.cmdList(driveId, null, true);
|
||||
Assertions.assertNotNull(listResult);
|
||||
Assertions.assertNotNull(listResult.getAnthers());
|
||||
Assertions.assertEquals(5, listResult.getAnthers().size());
|
||||
|
||||
Assertions.assertEquals("仙上主天", datfs.cmdGet(driveId, "仙上主天.txt").getResult());
|
||||
Assertions.assertEquals("𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", datfs.cmdGet(driveId, "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕.txt").getResult());
|
||||
Assertions.assertEquals("ᒡᒢᑊᒻᒻᓫᔿ", datfs.cmdGet(driveId, "ᒡᒢᑊᒻᒻᓫᔿ.txt").getResult());
|
||||
Assertions.assertEquals("𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕ᒡᒢᑊᒻᒻᓫᔿ仙上主天", datfs.cmdGet(driveId, "יֽ֕זְ֔/זֲ֟דֲ֩יֳ֟ײֳ֔יֳ֞וֶ֕זֵ֟ױֳ֩רְ֠װֶ֔רְ֠װֶ֔װֽ֕רֶ֔יֽ֔יֽ֔װֶ֕וְ֕ײֵ֔וֲ֩").getResult());
|
||||
|
||||
HyperLocalDriveInfo infoResult = datfs.cmdInfo(driveId);
|
||||
Assertions.assertNotNull(infoResult);
|
||||
Assertions.assertNotNull(infoResult.getDriveInfo(HyperLocalDriveInfoLine.KEY));
|
||||
Assertions.assertNotNull("5", infoResult.getDriveInfo(HyperLocalDriveInfoLine.VERSION));
|
||||
Assertions.assertEquals("true", infoResult.getDriveInfo(HyperLocalDriveInfoLine.WRITABLE));
|
||||
Assertions.assertNotNull(infoResult.getDriveInfo(HyperLocalDriveInfoLine.FILES_CORE_LENGTH));
|
||||
|
||||
datfs.cmdPurge(driveId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraFaultStackTraceJava3
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraFaultWarpVersion
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraRuntimeChapter
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraRuntimeThreads
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraSystemChapter
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraSystemLocale
|
||||
Loading…
Add table
Add a link
Reference in a new issue