All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
function getObjectSize(data) {
|
|
if (data && (typeof data === 'string' || data.byteLength)) {
|
|
return data.byteLength || data.length || 0;
|
|
}
|
|
return 0;
|
|
}
|
|
export const fileInfoHandler = {
|
|
addFileInfo(filePath, data) {
|
|
if (GameGlobal.manager.fs && GameGlobal.manager.fs.addFileInfo) {
|
|
GameGlobal.manager.fs.addFileInfo({ path: filePath, size: getObjectSize(data), erasable: false });
|
|
}
|
|
},
|
|
modifyFileInfo(filePath, data) {
|
|
if (GameGlobal.manager.fs && GameGlobal.manager.fs.modifyFileInfo) {
|
|
GameGlobal.manager.fs.modifyFileInfo({ path: filePath, size: getObjectSize(data) });
|
|
}
|
|
},
|
|
removeFileInfo(filePath) {
|
|
if (GameGlobal.manager.fs && GameGlobal.manager.fs.removeFileInfo) {
|
|
GameGlobal.manager.fs.removeFileInfo(filePath);
|
|
}
|
|
},
|
|
};
|
|
export const fileInfoType = {
|
|
add: 0,
|
|
remove: 1,
|
|
modify: 2,
|
|
};
|
|
export function responseWrapper(responseHandler, info) {
|
|
const { filePath, data, type } = info;
|
|
return {
|
|
success(res) {
|
|
if (type === fileInfoType.add) {
|
|
fileInfoHandler.addFileInfo(filePath, data);
|
|
}
|
|
if (type === fileInfoType.remove) {
|
|
fileInfoHandler.removeFileInfo(filePath);
|
|
}
|
|
if (type === fileInfoType.modify) {
|
|
fileInfoHandler.modifyFileInfo(filePath, data);
|
|
}
|
|
responseHandler.success(res);
|
|
},
|
|
fail: responseHandler.fail,
|
|
complete: responseHandler.complete,
|
|
};
|
|
}
|