decord/source/utils/FileManagerUtils.android.tsx

176 lines
5.2 KiB
TypeScript
Raw Normal View History

// Module ID: 8322
// Function ID: 8323
// Name: FileManagerUtils
// Dependencies: [5, 3, 1152, 2]
2026-07-20 16:05:17 +00:00
// Exports: clearFolder, moveFile, readFile, removeFile, writeFile
// Module 8322 (FileManagerUtils)
import LoggerDefault from "Logger" /* 3 */;
import NativeFileModuleDefault from "NativeFileModule" /* 1152 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
2026-07-22 07:54:56 +00:00
let closure_4 = async function _readFile(arg0, value) {
if (c8 === 2) {
c8 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp7 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c8 = 2;
if (0 === c7) {
2026-07-29 08:29:29 +00:00
if (arg0 === 1) {
c8 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
c8 = 3;
const obj4 = { value, done: true };
return obj4;
2026-07-29 08:29:29 +00:00
} else {
closure_4 = tmp3;
closure_3 = tmp5;
closure_131_0 = closure_1;
closure_131_1 = closure_2;
closure_131_2 = undefined;
const tmp36 = (function getBaseDirectory(arg0) {
if (null == closure_1_0(closure_1_1[2])) {
return null;
2026-07-29 08:29:29 +00:00
} else {
if ("cache" === arg0) {
let DocumentsDirPath = tmp(tmp2[2]).getConstants().CacheDirPath;
const tmpResult = tmp(tmp2[2]);
2026-07-29 08:29:29 +00:00
} else {
DocumentsDirPath = tmp(tmp2[2]).getConstants().DocumentsDirPath;
const tmpResult2 = tmp(tmp2[2]);
2026-07-29 08:29:29 +00:00
}
return DocumentsDirPath;
2026-07-29 08:29:29 +00:00
}
})(closure_0);
closure_131_2 = tmp36;
if (null == tmp36) {
2026-07-29 08:29:29 +00:00
c8 = 3;
return { value: null, done: true };
} else {
c7 = 1;
c8 = 1;
const obj5 = { value: NativeFileModuleDefault.fileExists(tmp36 + "/" + tmp34), done: false };
return obj5;
2026-07-29 08:29:29 +00:00
}
tmp34 = closure_1;
2026-07-29 08:29:29 +00:00
}
} else if (1 === tmp8) {
if (arg0 === 1) {
c8 = 3;
throw value;
} else if (arg0 === 2) {
c8 = 3;
const obj7 = { value, done: true };
return obj7;
} else if (value) {
c6 = 1;
c7 = 3;
c8 = 1;
const obj8 = { value: closure_132_0(closure_132_1[2]).readFile(closure_131_2 + "/" + closure_131_0, closure_131_1), done: false };
return obj8;
} else {
c8 = 3;
return { value: null, done: true };
}
} else if (2 === tmp8) {
c6 = 0;
closure_131_3 = closure_5;
closure_132_3.error("Failed to read file from disk", closure_131_3);
c8 = 3;
return { value: null, done: true };
} else if (arg0 === 1) {
c8 = 3;
throw value;
} else if (arg0 === 2) {
c6 = 0;
c8 = 3;
const obj9 = { value, done: true };
return obj9;
} else {
c6 = 0;
c8 = 3;
const obj = { value, done: true };
return obj;
2026-07-20 16:05:17 +00:00
}
} catch (tmp25) {
closure_5 = tmp25;
if (tmp4 === c6) {
c8 = tmp2;
throw tmp25;
} else {
c7 = tmp;
}
}
2026-07-20 16:05:17 +00:00
}
};
let closure_3 = new LoggerDefault("FileManagerUtils");
const size = fn(2);
const result = size.fileFinishedImporting("utils/FileManagerUtils.android.tsx");
2026-07-20 16:05:17 +00:00
export const writeFile = function writeFile(cache, arg1, arg2, utf8) {
const obj = NativeFileModuleDefault;
2026-07-20 16:05:17 +00:00
let nextPromise;
2026-07-29 08:29:29 +00:00
if (obj != null) {
nextPromise = obj.writeFile(cache, arg1, arg2, utf8).then((result) => "file:" + result);
const writeFileResult = obj.writeFile(cache, arg1, arg2, utf8);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (nextPromise == null) {
2026-07-20 16:05:17 +00:00
nextPromise = Promise.reject("RTNFileManager doesn't exist?");
}
return nextPromise;
};
export const moveFile = function moveFile(arg0, arg1, arg2) {
const obj = NativeFileModuleDefault;
2026-07-20 16:05:17 +00:00
let moveFileResult;
2026-07-29 08:29:29 +00:00
if (obj != null) {
moveFileResult = obj.moveFile(arg0, arg1, arg2);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (moveFileResult == null) {
2026-07-20 16:05:17 +00:00
moveFileResult = Promise.reject(false);
}
return moveFileResult;
};
export const removeFile = function removeFile(cache, filePathForGif) {
const obj = NativeFileModuleDefault;
2026-07-20 16:05:17 +00:00
let removeFileResult;
2026-07-29 08:29:29 +00:00
if (obj != null) {
removeFileResult = obj.removeFile(cache, filePathForGif);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (removeFileResult == null) {
2026-07-20 16:05:17 +00:00
removeFileResult = Promise.reject(false);
}
return removeFileResult;
};
export const clearFolder = function clearFolder(cache, arg1) {
const obj = NativeFileModuleDefault;
2026-07-20 16:05:17 +00:00
let clearFolderResult;
2026-07-29 08:29:29 +00:00
if (obj != null) {
clearFolderResult = obj.clearFolder(cache, arg1);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (clearFolderResult == null) {
2026-07-20 16:05:17 +00:00
clearFolderResult = Promise.reject(false);
}
return clearFolderResult;
};
export const readFile = function readFile() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = closure_4.apply;
2026-07-29 08:29:29 +00:00
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};