导航菜单

页面标题

页面副标题

MX Player v1.97.8 - Files.java 源代码

正在查看: MX Player v1.97.8 应用的 Files.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mxtech.io;

import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import com.microsoft.identity.common.java.WarningType;
import defpackage.edd;
import defpackage.fdd;
import defpackage.ls4;
import defpackage.mfg;
import defpackage.pcd;
import defpackage.r46;
import defpackage.rg2;
import defpackage.tya;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.Map;
import java.util.TreeMap;

public final class Files {
    public static Uri a;

    public class a implements FileFilter {
        public final pcd b;

        public a(pcd pcdVar) {
            this.b = pcdVar;
        }

        @Override
        public final boolean accept(File file) {
            if (!file.isDirectory()) {
                return false;
            }
            this.b.a(file.getPath());
            return false;
        }
    }

    public class b implements pcd {
        @Override
        public final void a(String str) {
            Files.d(str);
        }
    }

    public class c implements FileFilter {
        public final r46 b;

        public c(r46 r46Var) {
            this.b = r46Var;
        }

        @Override
        public final boolean accept(File file) {
            this.b.a(file);
            return false;
        }
    }

    public class d implements FileFilter {
        public final pcd b;

        public d(pcd pcdVar) {
            this.b = pcdVar;
        }

        @Override
        public final boolean accept(File file) {
            this.b.a(file.getPath());
            return false;
        }
    }

    public static final class e {
        public String a;

        @NonNull
        public String b;
        public String c;

        @NonNull
        public final File a() {
            StringBuilder sb = new StringBuilder();
            String str = this.a;
            if (str != null) {
                sb.append(str);
            }
            sb.append(File.separatorChar);
            sb.append(this.b);
            if (this.c != null) {
                sb.append('.');
                sb.append(this.c);
            }
            return new File(sb.toString());
        }
    }

    public static long A(String str) {
        return tya.p ? length_(str) : new File(str).length();
    }

    public static File[] B(File file) {
        if (!tya.p) {
            return file.listFiles();
        }
        try {
            Directory directory = new Directory(file.getPath());
            try {
                LinkedList linkedList = new LinkedList();
                while (true) {
                    String next = directory.next();
                    if (next == null) {
                        return (File[]) linkedList.toArray(new File[0]);
                    }
                    linkedList.add(new File(next));
                }
            } finally {
                directory.close();
            }
        } catch (IOException unused) {
            return null;
        }
    }

    public static File[] C(File file, FileFilter fileFilter) {
        if (!tya.p) {
            return file.listFiles(fileFilter);
        }
        try {
            Directory directory = new Directory(file.getPath());
            try {
                LinkedList linkedList = new LinkedList();
                while (true) {
                    String next = directory.next();
                    if (next == null) {
                        return (File[]) linkedList.toArray(new File[0]);
                    }
                    File file2 = new File(next);
                    if (fileFilter.accept(file2)) {
                        linkedList.add(file2);
                    }
                }
            } finally {
                directory.close();
            }
        } catch (IOException unused) {
            return null;
        }
    }

    public static boolean D(String str, String str2) {
        int lastIndexOf = str.lastIndexOf(File.separatorChar);
        if (lastIndexOf < 0) {
            return str.equals(str2);
        }
        int i = lastIndexOf + 1;
        int length = str2.length();
        if (str.length() - i == length) {
            return str.regionMatches(i, str2, 0, length);
        }
        return false;
    }

    public static OutputStream E(File file) throws IOException {
        String parent;
        ks4 b2;
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            Log.i("MX.Files", "Opened FileOuputStream for [" + file + "].");
            return fileOutputStream;
        } catch (IOException e2) {
            Log.w("MX.Files", e2 + " is thrown while opening [" + file + "] using FileOutputStream for writing.");
            ls4 c2 = ls4.c();
            c2.getClass();
            ks4 b3 = c2.b(file.getAbsolutePath());
            if (b3 == null && (parent = file.getParent()) != null && (b2 = c2.b(parent)) != null) {
                String name = file.getName();
                b3 = b2.c("text/subtitle", name);
                if (b3 != null) {
                    Log.i("MX.Files", "New document file [" + b3.i() + "] is created.");
                } else {
                    StringBuilder c3 = lg.c("Can't create document file with the name of '", name, "' under ");
                    c3.append(b2.i());
                    c3.append('.');
                    Log.w("MX.Files", c3.toString());
                }
            }
            if (b3 == null) {
                throw e2;
            }
            OutputStream openOutputStream = tya.m.getContentResolver().openOutputStream(b3.i());
            Log.i("MX.Files", "Opened OutputStream from ContentResolver for [" + b3.i() + "].");
            return openOutputStream;
        }
    }

    public static e F(@NonNull String str) {
        e eVar = new e();
        int length = str.length();
        int i = length - 1;
        int i2 = -1;
        int i3 = -1;
        while (i >= 0) {
            char charAt = str.charAt(i);
            if (charAt == '.') {
                if (i2 < 0) {
                    i2 = i;
                    if (i3 >= 0) {
                        break;
                    }
                } else {
                    continue;
                }
            } else if (charAt == File.separatorChar && i3 < 0) {
                if (i2 >= 0) {
                    break;
                }
                i3 = i;
            }
            i--;
        }
        i = i3;
        if (i > 0) {
            eVar.a = str.substring(0, i);
            if (i < i2) {
                eVar.c = str.substring(i2 + 1);
                eVar.b = str.substring(i + 1, i2);
            } else {
                eVar.c = null;
                eVar.b = str.substring(i + 1);
            }
        } else if (i != 0 || length <= 1) {
            eVar.a = null;
            eVar.b = "";
            eVar.c = null;
        } else {
            eVar.a = File.separator;
            if (i2 > 0) {
                eVar.c = str.substring(i2 + 1);
                eVar.b = str.substring(1, i2);
            } else {
                eVar.c = null;
                eVar.b = str.substring(1);
            }
        }
        return eVar;
    }

    @NonNull
    public static String G(@NonNull String str, @NonNull String str2) {
        int length = str.length();
        if (length == 0) {
            return str2;
        }
        char charAt = str.charAt(length - 1);
        char c2 = File.separatorChar;
        return charAt == c2 ? rg2.d(str, str2) : dsb.a(c2, str, str2);
    }

    public static boolean H(@NonNull File file) {
        try {
            File.createTempFile(".mxvp", null, file).delete();
            return true;
        } catch (IOException e2) {
            Log.w("MX.Files", "[" + file.getPath() + "] is NOT a writable directory - " + e2 + " is thrown while creating a temporary file.");
            ls4 c2 = ls4.c();
            c2.getClass();
            ks4 b2 = c2.b(file.getAbsolutePath());
            if (b2 == null) {
                Log.w("MX.Files", "DocumentFile is not found for [" + file + "].");
                return false;
            }
            boolean a2 = b2.a();
            if (a2) {
                Log.i("MX.Files", "DocumentFile [" + b2.i() + "] is writable.");
            } else {
                Log.w("MX.Files", "DocumentFile [" + b2.i() + "] is NOT writable.");
            }
            return a2;
        }
    }

    public static boolean I(File file, File file2) {
        if (file.renameTo(file2)) {
            return true;
        }
        if (mfg.g(file.getParent(), file2.getParent())) {
            ls4 c2 = ls4.c();
            c2.getClass();
            ks4 b2 = c2.b(file.getAbsolutePath());
            if (b2 != null) {
                if (b2.m(file2.getName())) {
                    return true;
                }
            }
        }
        return false;
    }

    @NonNull
    public static String J(@NonNull String str) {
        int length = str.length() - 1;
        int i = -1;
        int i2 = -1;
        while (length >= 0) {
            char charAt = str.charAt(length);
            if (charAt == '.') {
                if (i < 0) {
                    i = length;
                    if (i2 >= 0) {
                        break;
                    }
                } else {
                    continue;
                }
            } else if (charAt == File.separatorChar && i2 < 0) {
                if (i >= 0) {
                    break;
                }
                i2 = length;
            }
            length--;
        }
        length = i2;
        return length < i ? str.substring(0, i) : str;
    }

    public static void a(String str, String str2, byte[] bArr) throws IOException {
        FileOutputStream fileOutputStream;
        FileInputStream fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(str);
            try {
                fileOutputStream = new FileOutputStream(str2);
                try {
                    q96.s(fileInputStream2, fileOutputStream, bArr);
                    fileInputStream2.close();
                    fileOutputStream.close();
                } catch (Throwable th) {
                    th = th;
                    fileInputStream = fileInputStream2;
                    if (fileInputStream != null) {
                        fileInputStream.close();
                    }
                    if (fileOutputStream != null) {
                        fileOutputStream.close();
                    }
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = null;
            }
        } catch (Throwable th3) {
            th = th3;
            fileOutputStream = null;
        }
    }

    @SuppressLint({WarningType.NewApi})
    public static boolean b(ContentResolver contentResolver, File file) {
        String[] strArr;
        if (file.delete()) {
            return true;
        }
        try {
            ls4 c2 = ls4.c();
            c2.getClass();
            ks4 b2 = c2.b(file.getAbsolutePath());
            if (b2 != null) {
                if (b2.d()) {
                    return true;
                }
            }
            if (file.exists()) {
                if (file.isDirectory()) {
                    if (tya.p) {
                        try {
                            Directory directory = new Directory(file.getPath());
                            try {
                                LinkedList linkedList = new LinkedList();
                                while (true) {
                                    String nextName = directory.nextName();
                                    if (nextName == null) {
                                        break;
                                    }
                                    linkedList.add(nextName);
                                }
                                strArr = (String[]) linkedList.toArray(new String[0]);
                                directory.close();
                            } catch (Throwable th) {
                                directory.close();
                                throw th;
                            }
                        } catch (IOException unused) {
                            strArr = null;
                        }
                    } else {
                        strArr = file.list();
                    }
                    if (strArr == null || strArr.length > 0) {
                        return false;
                    }
                }
                if (a == null) {
                    a = MediaStore.Files.getContentUri("external");
                }
                String[] strArr2 = {file.getPath()};
                try {
                    contentResolver.delete(a, "_data=?", strArr2);
                    if (file.exists()) {
                        ContentValues contentValues = new ContentValues();
                        contentValues.put("_data", file.getPath());
                        contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
                        contentResolver.delete(a, "_data=?", strArr2);
                    }
                    return !file.exists();
                } catch (Exception e2) {
                    Log.e("MX.Files", "", e2);
                }
            }
        } catch (Exception unused2) {
        }
        return false;
    }

    public static boolean c(String str) {
        return tya.p ? delete_(str) : new File(str).delete();
    }

    public static native String canonicalize(@NonNull String str);

    public static native String canonicalizeCase(@NonNull String str);

    public static void d(String str) {
        if (u(str)) {
            i(str, new b());
        }
        boolean c2 = c(str);
        StringBuilder c3 = yyd.c(str, " is");
        c3.append(c2 ? "" : " NOT");
        c3.append(" deleted.");
        Log.i("MX.Files", c3.toString());
    }

    public static native boolean delete_(String str);

    public static boolean e(String str, String str2) {
        int lastIndexOf = str.lastIndexOf(46);
        if (lastIndexOf != str2.lastIndexOf(46)) {
            return false;
        }
        return str.regionMatches(true, 0, str2, 0, lastIndexOf);
    }

    public static native boolean existsCase(String str);

    private static native boolean exists_(String str);

    public static boolean f(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        return tya.p ? exists_(str) : new File(str).exists();
    }

    public static String g(fdd fddVar, String str) {
        String nextFilename;
        if (tya.p) {
            try {
                Directory directory = new Directory(str);
                while (true) {
                    try {
                        nextFilename = directory.nextFilename();
                        if (nextFilename == null) {
                            nextFilename = null;
                            break;
                        }
                        if (fddVar.a(nextFilename)) {
                            break;
                        }
                    } finally {
                        directory.close();
                    }
                }
                return nextFilename;
            } catch (IOException unused) {
            }
        } else {
            File[] listFiles = new File(str).listFiles(new com.mxtech.io.b(fddVar, str));
            if (listFiles != null && listFiles.length > 0) {
                return listFiles[0].getName();
            }
        }
        return null;
    }

    public static void h(File file, r46 r46Var) {
        if (!tya.p) {
            file.listFiles(new c(r46Var));
            return;
        }
        try {
            Directory directory = new Directory(file.getPath());
            while (true) {
                try {
                    String next = directory.next();
                    if (next == null) {
                        directory.close();
                        return;
                    }
                    r46Var.a(new File(next));
                } catch (Throwable th) {
                    directory.close();
                    throw th;
                }
            }
        } catch (IOException unused) {
        }
    }

    public static void i(String str, pcd pcdVar) {
        if (!tya.p) {
            new File(str).listFiles(new d(pcdVar));
            return;
        }
        try {
            Directory directory = new Directory(str);
            while (true) {
                try {
                    String next = directory.next();
                    if (next == null) {
                        directory.close();
                        return;
                    }
                    pcdVar.a(next);
                } catch (Throwable th) {
                    directory.close();
                    throw th;
                }
            }
        } catch (IOException unused) {
        }
    }

    private static native boolean isDirectory_(String str);

    private static native boolean isFile_(String str);

    public static native boolean isSameFile(String str, String str2) throws IOException;

    public static void j(String str, pcd pcdVar) {
        if (!tya.p) {
            new File(str).listFiles(new a(pcdVar));
            return;
        }
        try {
            Directory directory = new Directory(str);
            while (true) {
                try {
                    String nextDirectory = directory.nextDirectory();
                    if (nextDirectory == null) {
                        directory.close();
                        return;
                    }
                    pcdVar.a(nextDirectory);
                } catch (Throwable th) {
                    directory.close();
                    throw th;
                }
            }
        } catch (IOException unused) {
        }
    }

    public static void k(edd eddVar, String str) {
        if (!tya.p) {
            new File(str).listFiles(new com.mxtech.io.a(eddVar, str));
            return;
        }
        try {
            Directory directory = new Directory(str);
            while (true) {
                try {
                    String nextFilename = directory.nextFilename();
                    if (nextFilename == null) {
                        directory.close();
                        return;
                    }
                    eddVar.a(str, nextFilename);
                } catch (Throwable th) {
                    directory.close();
                    throw th;
                }
            }
        } catch (IOException unused) {
        }
    }

    public static File l(Uri uri) {
        if (v(uri)) {
            return new File(uri.getPath());
        }
        return null;
    }

    public static native long length_(String str);

    public static String m(@NonNull String str, @NonNull String str2) {
        int length = str.length();
        if (length == 0) {
            return str2;
        }
        if (str2.length() > length && str2.regionMatches(0, str, 0, length)) {
            char charAt = str.charAt(length - 1);
            char c2 = File.separatorChar;
            if (charAt != c2) {
                if (str2.charAt(length) == c2) {
                    length++;
                }
            }
            int indexOf = str2.indexOf(c2, length);
            return indexOf < 0 ? str2 : str2.substring(0, indexOf);
        }
        return null;
    }

    public static native boolean mkdir(@NonNull String str);

    public static native boolean mkdirs(@NonNull String str);

    public static String n(@NonNull String str) {
        int length = str.length() - 1;
        int i = -1;
        int i2 = -1;
        while (length >= 0) {
            char charAt = str.charAt(length);
            if (charAt == '.') {
                if (i < 0) {
                    i = length;
                    if (i2 >= 0) {
                        break;
                    }
                } else {
                    continue;
                }
            } else if (charAt == File.separatorChar && i2 < 0) {
                if (i >= 0) {
                    break;
                }
                i2 = length;
            }
            length--;
        }
        length = i2;
        if (length < i) {
            return str.substring(i + 1);
        }
        return null;
    }

    @NonNull
    public static String o(@NonNull String str) {
        int lastIndexOf = str.lastIndexOf(File.separatorChar);
        return lastIndexOf >= 0 ? str.substring(lastIndexOf + 1) : str;
    }

    public static File p(@NonNull String str, @NonNull String str2) {
        String str3;
        File file = new File(h7.b(str, "/", str2));
        int i = 1;
        while (file.exists()) {
            StringBuilder c2 = yyd.c(str, "/");
            int lastIndexOf = str2.lastIndexOf(".");
            if (lastIndexOf == -1) {
                str3 = str2 + "(" + i + ")";
            } else {
                str3 = str2.substring(0, lastIndexOf) + "(" + i + ")" + str2.substring(lastIndexOf);
            }
            c2.append(str3);
            file = new File(c2.toString());
            i++;
        }
        return file;
    }

    public static String q(@NonNull String str) {
        int lastIndexOf = str.lastIndexOf(File.separatorChar);
        if (lastIndexOf > 0) {
            return str.substring(0, lastIndexOf);
        }
        if (lastIndexOf != 0 || str.length() <= 1) {
            return null;
        }
        return File.separator;
    }

    @NonNull
    public static String r(@NonNull String str) {
        int length = str.length() - 1;
        int i = -1;
        int i2 = -1;
        while (length >= 0) {
            char charAt = str.charAt(length);
            if (charAt == '.') {
                if (i < 0) {
                    i = length;
                    if (i2 >= 0) {
                        break;
                    }
                } else {
                    continue;
                }
            } else if (charAt == File.separatorChar && i2 < 0) {
                if (i >= 0) {
                    break;
                }
                i2 = length;
            }
            length--;
        }
        length = i2;
        return length < i ? str.substring(length + 1, i) : str.substring(length + 1);
    }

    public static boolean s(@NonNull String str) {
        int i = 0;
        while (true) {
            int indexOf = str.indexOf(46, i);
            if (indexOf < 0) {
                return false;
            }
            if (indexOf == 0 || str.charAt(indexOf - 1) == File.separatorChar) {
                return true;
            }
            i = indexOf + 1;
        }
    }

    public static native long stat0(String str);

    public static native long stat0Case(String str);

    public static native boolean stat1(String str, FileStat1 fileStat1);

    public static boolean t(@NonNull String str, @NonNull String str2) {
        int length = str2.length();
        if (length == 0) {
            return true;
        }
        int length2 = str.length();
        if (length2 > length && str.regionMatches(0, str2, 0, length)) {
            char charAt = str2.charAt(length - 1);
            char c2 = File.separatorChar;
            if (charAt != c2) {
                if (str.charAt(length) == c2) {
                    length++;
                }
            }
            int indexOf = str.indexOf(c2, length);
            return indexOf < 0 || indexOf == length2 - 1;
        }
        return false;
    }

    public static boolean u(String str) {
        return tya.p ? isDirectory_(str) : new File(str).isDirectory();
    }

    public static boolean v(@NonNull Uri uri) {
        String scheme = uri.getScheme();
        return scheme == null || "file".equals(scheme) || "usb".equals(scheme);
    }

    public static boolean w(@NonNull String str, @NonNull String str2) {
        if (!str.startsWith(str2)) {
            return false;
        }
        int length = str2.length();
        return str.length() == length || str.charAt(length) == File.separatorChar;
    }

    public static boolean x(@NonNull String str, @NonNull TreeMap treeMap) {
        for (Map.Entry entry : treeMap.entrySet()) {
            if (w(str, (String) entry.getKey())) {
                return (((Integer) entry.getValue()).intValue() & 1) != 0;
            }
        }
        return false;
    }

    public static boolean y(String str) {
        return (TextUtils.isEmpty(str) ? false : tya.p ? isFile_(str) : new File(str).isFile()) && new File(str).canRead();
    }

    public static boolean z(String str) {
        return str != null && str.startsWith("usb:///");
    }
}