BBASMSubDirectoryManagerProtocol.h
3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
// BBASMSubDirectoryManagerProtocol.h
// SWAN
//
// Created by baidu on 2018/10/29.
// Copyright © 2018 baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Pyramid/Pyramid.h>
AliasService(BBASMSubDirectoryManagerProtocol, bba_MNPSubDirectoryManager)
@class BBASchemeDispatcher;
typedef NS_ENUM(NSUInteger, BBASMSubDirectoryName) {
BBASMSubDirectoryTmp = 1,
BBASMSubDirectoryStore = 2,
BBASMSubDirectoryImage = 3,
};
/**
* 包括除预置directory之外的四个文件夹,包括: video,pic,tmp和store文件夹。
* 不需要自己再创建,直接使用即可。
*/
@protocol BBASMSubDirectoryManagerProtocol <NSObject>
#pragma mark - 所有的路径
/**
* 返回小程序appId
*/
+(NSString *)swapAppId:(BBASchemeDispatcher *)dispatcher;
/**
* 返回小程序沙盒子文件夹目录
* 参数:appId
directory,枚举值,目前有四个子文件夹
*/
+(NSString *)swapSubDirectoryPath:(NSString *)appId
directory:(BBASMSubDirectoryName)directory;
/**
* 将小程序相对路径转为绝对路径 例:前端传过来的文件名,转为绝对路径
*/
+(NSString *)inverseFileNameToDefinatePath:(NSString *)fileName
appId:(NSString *)appId;
/**
* 文件路径转为文件名
* 参数path: 可以是相对路径,也可以是绝对路径
* 返回值:js需要的文件名,以bdfile开头
*/
+(NSString *)fileNameByPath:(NSString *)path
andAppId:(NSString *)appId;
/**
* 将小程序包内的相对路径转换为宿主app内的绝对路径
*/
+ (NSString *)absolutePathWithBBASMAppRelativepath:(NSString *)relativePath appID:(NSString *)appID;
/**
* @brief 获取指定path下的文件列表,文件信息包括路径、大小和保存时间戳
*
* @param path 路径(可能包含子目录)
* @param appID 小程序appID
* @return 指定path下的文件列表
*/
+ (NSArray *)fileInfoListWithPath:(NSString *)path
appID:(NSString *)appID;
/**
* @brief 获取指定path下的文件列表,文件信息包括路径、大小和保存时间戳
*
* @param path 路径(不包含子目录)
* @param appID 小程序appID
* @return 指定path下的文件列表
*/
+ (NSDictionary *)fileInfoDictWithPath:(NSString *)path
needBDFileURL:(BOOL)needBDFileURL
appID:(NSString *)appID;
#pragma mark - 文件管理的方法
/**
* 创建所有文件夹
*/
+(void)createAllSubDirectoryByAppId:(NSString *)appId;
/// 小程序子目录名称数组
+ (NSArray *)allSubDirectoryNamesArray;
/*
* 读写操作在下面的队列里面执行。
* action:要做的读写操作
* completion: 读写完成回调
*/
+(void)readWriteOnMnpIOQueue:(void (^)(void))action completion:(void (^)(void))completion;
/**
* 清理文件夹
* 参数:
* time: 文件的过期时间
* maxSize: 文件最大的缓存量 单位字节
*/
+(void)cleanDirectory:(NSString *)directoryPath expireTime:(NSTimeInterval)time andMaxSize:(double)maxSize;
///小程序即将退出
+(void)bbasmWillEnterBackground:(NSString *)appId;
/**
* 清除指定小程序的tmp目录
*/
+(void)cleanTmpDir:(NSString *)appId;
@end