- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
330 lines
13 KiB
Java
330 lines
13 KiB
Java
package kotlin.io;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayDeque;
|
|
import java.util.Iterator;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.collections.AbstractIterator;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.sequences.Sequence;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public final class FileTreeWalk implements Sequence {
|
|
public final FileWalkDirection direction;
|
|
public final int maxDepth;
|
|
public final Function1 onEnter;
|
|
public final Function2 onFail;
|
|
public final Function1 onLeave;
|
|
public final File start;
|
|
|
|
public FileTreeWalk(File file, FileWalkDirection fileWalkDirection, Function1 function1, Function1 function12, Function2 function2, int i) {
|
|
this.start = file;
|
|
this.direction = fileWalkDirection;
|
|
this.onEnter = function1;
|
|
this.onLeave = function12;
|
|
this.onFail = function2;
|
|
this.maxDepth = i;
|
|
}
|
|
|
|
public /* synthetic */ FileTreeWalk(File file, FileWalkDirection fileWalkDirection, Function1 function1, Function1 function12, Function2 function2, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(file, (i2 & 2) != 0 ? FileWalkDirection.TOP_DOWN : fileWalkDirection, function1, function12, function2, (i2 & 32) != 0 ? Integer.MAX_VALUE : i);
|
|
}
|
|
|
|
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
|
public FileTreeWalk(File start, FileWalkDirection direction) {
|
|
this(start, direction, null, null, null, 0, 32, null);
|
|
Intrinsics.checkNotNullParameter(start, "start");
|
|
Intrinsics.checkNotNullParameter(direction, "direction");
|
|
}
|
|
|
|
@Override // kotlin.sequences.Sequence
|
|
public Iterator iterator() {
|
|
return new FileTreeWalkIterator();
|
|
}
|
|
|
|
public static abstract class WalkState {
|
|
public final File root;
|
|
|
|
public final File getRoot() {
|
|
return this.root;
|
|
}
|
|
|
|
public abstract File step();
|
|
|
|
public WalkState(File root) {
|
|
Intrinsics.checkNotNullParameter(root, "root");
|
|
this.root = root;
|
|
}
|
|
}
|
|
|
|
public static abstract class DirectoryState extends WalkState {
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public DirectoryState(File rootDir) {
|
|
super(rootDir);
|
|
Intrinsics.checkNotNullParameter(rootDir, "rootDir");
|
|
}
|
|
}
|
|
|
|
public final class FileTreeWalkIterator extends AbstractIterator {
|
|
public final ArrayDeque state;
|
|
|
|
public /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
int[] iArr = new int[FileWalkDirection.values().length];
|
|
try {
|
|
iArr[FileWalkDirection.TOP_DOWN.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
iArr[FileWalkDirection.BOTTOM_UP.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
$EnumSwitchMapping$0 = iArr;
|
|
}
|
|
}
|
|
|
|
public FileTreeWalkIterator() {
|
|
ArrayDeque arrayDeque = new ArrayDeque();
|
|
this.state = arrayDeque;
|
|
if (FileTreeWalk.this.start.isDirectory()) {
|
|
arrayDeque.push(directoryState(FileTreeWalk.this.start));
|
|
} else if (FileTreeWalk.this.start.isFile()) {
|
|
arrayDeque.push(new SingleFileState(this, FileTreeWalk.this.start));
|
|
} else {
|
|
done();
|
|
}
|
|
}
|
|
|
|
@Override // kotlin.collections.AbstractIterator
|
|
public void computeNext() {
|
|
File gotoNext = gotoNext();
|
|
if (gotoNext != null) {
|
|
setNext(gotoNext);
|
|
} else {
|
|
done();
|
|
}
|
|
}
|
|
|
|
public final DirectoryState directoryState(File file) {
|
|
int i = WhenMappings.$EnumSwitchMapping$0[FileTreeWalk.this.direction.ordinal()];
|
|
if (i == 1) {
|
|
return new TopDownDirectoryState(this, file);
|
|
}
|
|
if (i == 2) {
|
|
return new BottomUpDirectoryState(this, file);
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
|
|
public final File gotoNext() {
|
|
File step;
|
|
while (true) {
|
|
WalkState walkState = (WalkState) this.state.peek();
|
|
if (walkState == null) {
|
|
return null;
|
|
}
|
|
step = walkState.step();
|
|
if (step == null) {
|
|
this.state.pop();
|
|
} else {
|
|
if (Intrinsics.areEqual(step, walkState.getRoot()) || !step.isDirectory() || this.state.size() >= FileTreeWalk.this.maxDepth) {
|
|
break;
|
|
}
|
|
this.state.push(directoryState(step));
|
|
}
|
|
}
|
|
return step;
|
|
}
|
|
|
|
public final class BottomUpDirectoryState extends DirectoryState {
|
|
public boolean failed;
|
|
public int fileIndex;
|
|
public File[] fileList;
|
|
public boolean rootVisited;
|
|
public final /* synthetic */ FileTreeWalkIterator this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public BottomUpDirectoryState(FileTreeWalkIterator fileTreeWalkIterator, File rootDir) {
|
|
super(rootDir);
|
|
Intrinsics.checkNotNullParameter(rootDir, "rootDir");
|
|
this.this$0 = fileTreeWalkIterator;
|
|
}
|
|
|
|
@Override // kotlin.io.FileTreeWalk.WalkState
|
|
public File step() {
|
|
if (!this.failed && this.fileList == null) {
|
|
Function1 function1 = FileTreeWalk.this.onEnter;
|
|
if (function1 != null && !((Boolean) function1.invoke(getRoot())).booleanValue()) {
|
|
return null;
|
|
}
|
|
File[] listFiles = getRoot().listFiles();
|
|
this.fileList = listFiles;
|
|
if (listFiles == null) {
|
|
Function2 function2 = FileTreeWalk.this.onFail;
|
|
if (function2 != null) {
|
|
function2.invoke(getRoot(), new AccessDeniedException(getRoot(), null, "Cannot list files in a directory", 2, null));
|
|
}
|
|
this.failed = true;
|
|
}
|
|
}
|
|
File[] fileArr = this.fileList;
|
|
if (fileArr != null) {
|
|
int i = this.fileIndex;
|
|
Intrinsics.checkNotNull(fileArr);
|
|
if (i < fileArr.length) {
|
|
File[] fileArr2 = this.fileList;
|
|
Intrinsics.checkNotNull(fileArr2);
|
|
int i2 = this.fileIndex;
|
|
this.fileIndex = i2 + 1;
|
|
return fileArr2[i2];
|
|
}
|
|
}
|
|
if (this.rootVisited) {
|
|
Function1 function12 = FileTreeWalk.this.onLeave;
|
|
if (function12 != null) {
|
|
function12.invoke(getRoot());
|
|
}
|
|
return null;
|
|
}
|
|
this.rootVisited = true;
|
|
return getRoot();
|
|
}
|
|
}
|
|
|
|
public final class TopDownDirectoryState extends DirectoryState {
|
|
public int fileIndex;
|
|
public File[] fileList;
|
|
public boolean rootVisited;
|
|
public final /* synthetic */ FileTreeWalkIterator this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public TopDownDirectoryState(FileTreeWalkIterator fileTreeWalkIterator, File rootDir) {
|
|
super(rootDir);
|
|
Intrinsics.checkNotNullParameter(rootDir, "rootDir");
|
|
this.this$0 = fileTreeWalkIterator;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:29:0x007f, code lost:
|
|
|
|
if (r0.length == 0) goto L31;
|
|
*/
|
|
@Override // kotlin.io.FileTreeWalk.WalkState
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public java.io.File step() {
|
|
/*
|
|
r10 = this;
|
|
boolean r0 = r10.rootVisited
|
|
r1 = 0
|
|
if (r0 != 0) goto L28
|
|
kotlin.io.FileTreeWalk$FileTreeWalkIterator r0 = r10.this$0
|
|
kotlin.io.FileTreeWalk r0 = kotlin.io.FileTreeWalk.this
|
|
kotlin.jvm.functions.Function1 r0 = kotlin.io.FileTreeWalk.access$getOnEnter$p(r0)
|
|
if (r0 == 0) goto L20
|
|
java.io.File r2 = r10.getRoot()
|
|
java.lang.Object r0 = r0.invoke(r2)
|
|
java.lang.Boolean r0 = (java.lang.Boolean) r0
|
|
boolean r0 = r0.booleanValue()
|
|
if (r0 != 0) goto L20
|
|
return r1
|
|
L20:
|
|
r0 = 1
|
|
r10.rootVisited = r0
|
|
java.io.File r0 = r10.getRoot()
|
|
return r0
|
|
L28:
|
|
java.io.File[] r0 = r10.fileList
|
|
if (r0 == 0) goto L47
|
|
int r2 = r10.fileIndex
|
|
kotlin.jvm.internal.Intrinsics.checkNotNull(r0)
|
|
int r0 = r0.length
|
|
if (r2 >= r0) goto L35
|
|
goto L47
|
|
L35:
|
|
kotlin.io.FileTreeWalk$FileTreeWalkIterator r0 = r10.this$0
|
|
kotlin.io.FileTreeWalk r0 = kotlin.io.FileTreeWalk.this
|
|
kotlin.jvm.functions.Function1 r0 = kotlin.io.FileTreeWalk.access$getOnLeave$p(r0)
|
|
if (r0 == 0) goto L46
|
|
java.io.File r2 = r10.getRoot()
|
|
r0.invoke(r2)
|
|
L46:
|
|
return r1
|
|
L47:
|
|
java.io.File[] r0 = r10.fileList
|
|
if (r0 != 0) goto L93
|
|
java.io.File r0 = r10.getRoot()
|
|
java.io.File[] r0 = r0.listFiles()
|
|
r10.fileList = r0
|
|
if (r0 != 0) goto L77
|
|
kotlin.io.FileTreeWalk$FileTreeWalkIterator r0 = r10.this$0
|
|
kotlin.io.FileTreeWalk r0 = kotlin.io.FileTreeWalk.this
|
|
kotlin.jvm.functions.Function2 r0 = kotlin.io.FileTreeWalk.access$getOnFail$p(r0)
|
|
if (r0 == 0) goto L77
|
|
java.io.File r2 = r10.getRoot()
|
|
kotlin.io.AccessDeniedException r9 = new kotlin.io.AccessDeniedException
|
|
java.io.File r4 = r10.getRoot()
|
|
r5 = 0
|
|
java.lang.String r6 = "Cannot list files in a directory"
|
|
r7 = 2
|
|
r8 = 0
|
|
r3 = r9
|
|
r3.<init>(r4, r5, r6, r7, r8)
|
|
r0.invoke(r2, r9)
|
|
L77:
|
|
java.io.File[] r0 = r10.fileList
|
|
if (r0 == 0) goto L81
|
|
kotlin.jvm.internal.Intrinsics.checkNotNull(r0)
|
|
int r0 = r0.length
|
|
if (r0 != 0) goto L93
|
|
L81:
|
|
kotlin.io.FileTreeWalk$FileTreeWalkIterator r0 = r10.this$0
|
|
kotlin.io.FileTreeWalk r0 = kotlin.io.FileTreeWalk.this
|
|
kotlin.jvm.functions.Function1 r0 = kotlin.io.FileTreeWalk.access$getOnLeave$p(r0)
|
|
if (r0 == 0) goto L92
|
|
java.io.File r2 = r10.getRoot()
|
|
r0.invoke(r2)
|
|
L92:
|
|
return r1
|
|
L93:
|
|
java.io.File[] r0 = r10.fileList
|
|
kotlin.jvm.internal.Intrinsics.checkNotNull(r0)
|
|
int r1 = r10.fileIndex
|
|
int r2 = r1 + 1
|
|
r10.fileIndex = r2
|
|
r0 = r0[r1]
|
|
return r0
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: kotlin.io.FileTreeWalk.FileTreeWalkIterator.TopDownDirectoryState.step():java.io.File");
|
|
}
|
|
}
|
|
|
|
public final class SingleFileState extends WalkState {
|
|
public final /* synthetic */ FileTreeWalkIterator this$0;
|
|
public boolean visited;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public SingleFileState(FileTreeWalkIterator fileTreeWalkIterator, File rootFile) {
|
|
super(rootFile);
|
|
Intrinsics.checkNotNullParameter(rootFile, "rootFile");
|
|
this.this$0 = fileTreeWalkIterator;
|
|
}
|
|
|
|
@Override // kotlin.io.FileTreeWalk.WalkState
|
|
public File step() {
|
|
if (this.visited) {
|
|
return null;
|
|
}
|
|
this.visited = true;
|
|
return getRoot();
|
|
}
|
|
}
|
|
}
|
|
}
|