mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Move FS support to teavm-core module
This commit is contained in:
parent
bb087b7630
commit
3eb4b742ea
|
@ -23,10 +23,10 @@ import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
|
||||||
import org.teavm.classlib.fs.VirtualFileSystem;
|
|
||||||
import org.teavm.classlib.fs.VirtualFileSystemProvider;
|
|
||||||
import org.teavm.classlib.java.util.TRandom;
|
import org.teavm.classlib.java.util.TRandom;
|
||||||
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileSystem;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileSystemProvider;
|
||||||
|
|
||||||
public class TFile implements Serializable, Comparable<TFile> {
|
public class TFile implements Serializable, Comparable<TFile> {
|
||||||
private String path;
|
private String path;
|
||||||
|
|
|
@ -19,8 +19,8 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class TFileInputStream extends InputStream {
|
public class TFileInputStream extends InputStream {
|
||||||
private static final byte[] ONE_BYTE_BUFFER = new byte[1];
|
private static final byte[] ONE_BYTE_BUFFER = new byte[1];
|
||||||
|
|
|
@ -20,8 +20,8 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class TFileOutputStream extends OutputStream {
|
public class TFileOutputStream extends OutputStream {
|
||||||
private static final byte[] ONE_BYTE_BUFER = new byte[1];
|
private static final byte[] ONE_BYTE_BUFER = new byte[1];
|
||||||
|
|
|
@ -23,10 +23,10 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UTFDataFormatException;
|
import java.io.UTFDataFormatException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
|
||||||
import org.teavm.classlib.java.lang.TIndexOutOfBoundsException;
|
import org.teavm.classlib.java.lang.TIndexOutOfBoundsException;
|
||||||
import org.teavm.classlib.java.lang.TNullPointerException;
|
import org.teavm.classlib.java.lang.TNullPointerException;
|
||||||
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class TRandomAccessFile implements DataInput, DataOutput, Closeable {
|
public class TRandomAccessFile implements DataInput, DataOutput, Closeable {
|
||||||
private static final byte[] ONE_BYTE_BUFFER = new byte[1];
|
private static final byte[] ONE_BYTE_BUFFER = new byte[1];
|
||||||
|
|
|
@ -18,12 +18,11 @@ package org.teavm.classlib.java.lang;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.teavm.backend.c.intrinsic.RuntimeInclude;
|
import org.teavm.backend.c.intrinsic.RuntimeInclude;
|
||||||
|
import org.teavm.backend.c.runtime.Memory;
|
||||||
|
import org.teavm.backend.c.runtime.fs.CFileSystem;
|
||||||
import org.teavm.backend.javascript.spi.GeneratedBy;
|
import org.teavm.backend.javascript.spi.GeneratedBy;
|
||||||
import org.teavm.backend.wasm.runtime.WasmSupport;
|
import org.teavm.backend.wasm.runtime.WasmSupport;
|
||||||
import org.teavm.classlib.PlatformDetector;
|
import org.teavm.classlib.PlatformDetector;
|
||||||
import org.teavm.classlib.fs.VirtualFileSystemProvider;
|
|
||||||
import org.teavm.classlib.fs.c.CFileSystem;
|
|
||||||
import org.teavm.classlib.impl.c.Memory;
|
|
||||||
import org.teavm.classlib.impl.console.StderrOutputStream;
|
import org.teavm.classlib.impl.console.StderrOutputStream;
|
||||||
import org.teavm.classlib.impl.console.StdoutOutputStream;
|
import org.teavm.classlib.impl.console.StdoutOutputStream;
|
||||||
import org.teavm.classlib.java.io.TConsole;
|
import org.teavm.classlib.java.io.TConsole;
|
||||||
|
@ -41,6 +40,7 @@ import org.teavm.runtime.Allocator;
|
||||||
import org.teavm.runtime.GC;
|
import org.teavm.runtime.GC;
|
||||||
import org.teavm.runtime.RuntimeArray;
|
import org.teavm.runtime.RuntimeArray;
|
||||||
import org.teavm.runtime.RuntimeClass;
|
import org.teavm.runtime.RuntimeClass;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileSystemProvider;
|
||||||
|
|
||||||
public final class TSystem extends TObject {
|
public final class TSystem extends TObject {
|
||||||
private static TPrintStream outCache;
|
private static TPrintStream outCache;
|
||||||
|
|
|
@ -75,6 +75,7 @@ import org.teavm.backend.c.intrinsic.RuntimeClassIntrinsic;
|
||||||
import org.teavm.backend.c.intrinsic.ShadowStackIntrinsic;
|
import org.teavm.backend.c.intrinsic.ShadowStackIntrinsic;
|
||||||
import org.teavm.backend.c.intrinsic.StringsIntrinsic;
|
import org.teavm.backend.c.intrinsic.StringsIntrinsic;
|
||||||
import org.teavm.backend.c.intrinsic.StructureIntrinsic;
|
import org.teavm.backend.c.intrinsic.StructureIntrinsic;
|
||||||
|
import org.teavm.backend.c.transform.CFileSystemTransformer;
|
||||||
import org.teavm.backend.lowlevel.analyze.LowLevelInliningFilterFactory;
|
import org.teavm.backend.lowlevel.analyze.LowLevelInliningFilterFactory;
|
||||||
import org.teavm.backend.lowlevel.dependency.ExceptionHandlingDependencyListener;
|
import org.teavm.backend.lowlevel.dependency.ExceptionHandlingDependencyListener;
|
||||||
import org.teavm.backend.lowlevel.dependency.StringsDependencyListener;
|
import org.teavm.backend.lowlevel.dependency.StringsDependencyListener;
|
||||||
|
@ -227,6 +228,7 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||||
transformers.add(new ClassPatch());
|
transformers.add(new ClassPatch());
|
||||||
transformers.add(new CDependencyListener());
|
transformers.add(new CDependencyListener());
|
||||||
transformers.add(new WeakReferenceTransformation());
|
transformers.add(new WeakReferenceTransformation());
|
||||||
|
transformers.add(new CFileSystemTransformer());
|
||||||
return transformers;
|
return transformers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.impl.c;
|
package org.teavm.backend.c.runtime;
|
||||||
|
|
||||||
import org.teavm.interop.Structure;
|
import org.teavm.interop.Structure;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.impl.c;
|
package org.teavm.backend.c.runtime;
|
||||||
|
|
||||||
import org.teavm.interop.Address;
|
import org.teavm.interop.Address;
|
||||||
import org.teavm.interop.Import;
|
import org.teavm.interop.Import;
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.impl.c;
|
package org.teavm.backend.c.runtime;
|
||||||
|
|
||||||
import org.teavm.interop.Structure;
|
import org.teavm.interop.Structure;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,20 +13,20 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.c;
|
package org.teavm.backend.c.runtime.fs;
|
||||||
|
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.teavm.backend.c.intrinsic.RuntimeInclude;
|
import org.teavm.backend.c.intrinsic.RuntimeInclude;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.backend.c.runtime.Memory;
|
||||||
import org.teavm.classlib.fs.VirtualFileSystem;
|
import org.teavm.backend.c.runtime.StringList;
|
||||||
import org.teavm.classlib.impl.c.Memory;
|
|
||||||
import org.teavm.classlib.impl.c.StringList;
|
|
||||||
import org.teavm.interop.Address;
|
import org.teavm.interop.Address;
|
||||||
import org.teavm.interop.Import;
|
import org.teavm.interop.Import;
|
||||||
import org.teavm.interop.Unmanaged;
|
import org.teavm.interop.Unmanaged;
|
||||||
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileSystem;
|
||||||
|
|
||||||
public class CFileSystem implements VirtualFileSystem {
|
public class CFileSystem implements VirtualFileSystem {
|
||||||
private Map<String, Entry> cache = new HashMap<>();
|
private Map<String, Entry> cache = new HashMap<>();
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,17 +13,17 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.c;
|
package org.teavm.backend.c.runtime.fs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.backend.c.runtime.Memory;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.backend.c.runtime.StringList;
|
||||||
import org.teavm.classlib.impl.c.Memory;
|
|
||||||
import org.teavm.classlib.impl.c.StringList;
|
|
||||||
import org.teavm.interop.Address;
|
import org.teavm.interop.Address;
|
||||||
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class CVirtualFile implements VirtualFile {
|
public class CVirtualFile implements VirtualFile {
|
||||||
CFileSystem fileSystem;
|
CFileSystem fileSystem;
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,10 +13,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.c;
|
package org.teavm.backend.c.runtime.fs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class CVirtualFileAccessor implements VirtualFileAccessor {
|
public class CVirtualFileAccessor implements VirtualFileAccessor {
|
||||||
private long file;
|
private long file;
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* 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 org.teavm.backend.c.transform;
|
||||||
|
|
||||||
|
import org.teavm.backend.c.runtime.fs.CFileSystem;
|
||||||
|
import org.teavm.model.ClassHolderTransformerContext;
|
||||||
|
import org.teavm.model.MethodHolder;
|
||||||
|
import org.teavm.model.emit.ProgramEmitter;
|
||||||
|
import org.teavm.runtime.fs.VirtualFileSystemProviderTransformer;
|
||||||
|
|
||||||
|
public class CFileSystemTransformer extends VirtualFileSystemProviderTransformer {
|
||||||
|
@Override
|
||||||
|
protected void transformCreateMethod(MethodHolder method, ClassHolderTransformerContext context) {
|
||||||
|
ProgramEmitter pe = ProgramEmitter.create(method, context.getHierarchy());
|
||||||
|
pe.construct(CFileSystem.class).returnValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs;
|
package org.teavm.runtime.fs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs;
|
package org.teavm.runtime.fs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs;
|
package org.teavm.runtime.fs;
|
||||||
|
|
||||||
public interface VirtualFileSystem {
|
public interface VirtualFileSystem {
|
||||||
String getUserDir();
|
String getUserDir();
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 Alexey Andreev.
|
* Copyright 2022 Alexey Andreev.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,30 +13,27 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs;
|
package org.teavm.runtime.fs;
|
||||||
|
|
||||||
import org.teavm.classlib.PlatformDetector;
|
import org.teavm.runtime.fs.memory.InMemoryVirtualFileSystem;
|
||||||
import org.teavm.classlib.fs.c.CFileSystem;
|
|
||||||
import org.teavm.classlib.fs.memory.InMemoryVirtualFileSystem;
|
|
||||||
|
|
||||||
public final class VirtualFileSystemProvider {
|
public final class VirtualFileSystemProvider {
|
||||||
private static VirtualFileSystem instance;
|
private static VirtualFileSystem instance;
|
||||||
|
|
||||||
static {
|
|
||||||
if (PlatformDetector.isC()) {
|
|
||||||
instance = new CFileSystem();
|
|
||||||
} else {
|
|
||||||
instance = new InMemoryVirtualFileSystem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private VirtualFileSystemProvider() {
|
private VirtualFileSystemProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VirtualFileSystem getInstance() {
|
public static VirtualFileSystem getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = create();
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static VirtualFileSystem create() {
|
||||||
|
return new InMemoryVirtualFileSystem();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setInstance(VirtualFileSystem instance) {
|
public static void setInstance(VirtualFileSystem instance) {
|
||||||
VirtualFileSystemProvider.instance = instance;
|
VirtualFileSystemProvider.instance = instance;
|
||||||
}
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* 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 org.teavm.runtime.fs;
|
||||||
|
|
||||||
|
import org.teavm.model.ClassHolder;
|
||||||
|
import org.teavm.model.ClassHolderTransformer;
|
||||||
|
import org.teavm.model.ClassHolderTransformerContext;
|
||||||
|
import org.teavm.model.MethodDescriptor;
|
||||||
|
import org.teavm.model.MethodHolder;
|
||||||
|
|
||||||
|
public abstract class VirtualFileSystemProviderTransformer implements ClassHolderTransformer {
|
||||||
|
@Override
|
||||||
|
public void transformClass(ClassHolder cls, ClassHolderTransformerContext context) {
|
||||||
|
if (cls.getName().equals(VirtualFileSystemProvider.class.getName())) {
|
||||||
|
MethodHolder method = cls.getMethod(new MethodDescriptor("create", VirtualFileSystem.class));
|
||||||
|
transformCreateMethod(method, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void transformCreateMethod(MethodHolder method, ClassHolderTransformerContext context);
|
||||||
|
}
|
|
@ -13,10 +13,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.memory;
|
package org.teavm.runtime.fs.memory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public abstract class AbstractInMemoryVirtualFile {
|
public abstract class AbstractInMemoryVirtualFile {
|
||||||
String name;
|
String name;
|
|
@ -13,12 +13,12 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.memory;
|
package org.teavm.runtime.fs.memory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class InMemoryVirtualDirectory extends AbstractInMemoryVirtualFile {
|
public class InMemoryVirtualDirectory extends AbstractInMemoryVirtualFile {
|
||||||
final Map<String, AbstractInMemoryVirtualFile> children = new LinkedHashMap<>();
|
final Map<String, AbstractInMemoryVirtualFile> children = new LinkedHashMap<>();
|
|
@ -13,11 +13,11 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.memory;
|
package org.teavm.runtime.fs.memory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class InMemoryVirtualFile extends AbstractInMemoryVirtualFile {
|
public class InMemoryVirtualFile extends AbstractInMemoryVirtualFile {
|
||||||
byte[] data = new byte[0];
|
byte[] data = new byte[0];
|
|
@ -13,10 +13,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.memory;
|
package org.teavm.runtime.fs.memory;
|
||||||
|
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
import org.teavm.classlib.fs.VirtualFileSystem;
|
import org.teavm.runtime.fs.VirtualFileSystem;
|
||||||
|
|
||||||
public class InMemoryVirtualFileSystem implements VirtualFileSystem {
|
public class InMemoryVirtualFileSystem implements VirtualFileSystem {
|
||||||
InMemoryVirtualDirectory root = new InMemoryVirtualDirectory("");
|
InMemoryVirtualDirectory root = new InMemoryVirtualDirectory("");
|
|
@ -13,11 +13,11 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.fs.memory;
|
package org.teavm.runtime.fs.memory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.teavm.classlib.fs.VirtualFile;
|
import org.teavm.runtime.fs.VirtualFile;
|
||||||
import org.teavm.classlib.fs.VirtualFileAccessor;
|
import org.teavm.runtime.fs.VirtualFileAccessor;
|
||||||
|
|
||||||
public class VirtualFileImpl implements VirtualFile {
|
public class VirtualFileImpl implements VirtualFile {
|
||||||
private InMemoryVirtualFileSystem fs;
|
private InMemoryVirtualFileSystem fs;
|
Loading…
Reference in New Issue
Block a user