1 //
2 //  FileLoader.hpp
3 //  MNN
4 //
5 //  Created by MNN on 2019/07/04.
6 //  Copyright © 2018, Alibaba Group Holding Limited
7 //
8 
9 #include <vector>
10 #include "core/AutoStorage.h"
11 namespace MNN {
12 class MNN_PUBLIC FileLoader {
13 public:
14     FileLoader(const char* file);
15 
16     ~FileLoader();
17 
18     bool read();
19 
valid() const20     bool valid() const {
21         return mFile != nullptr;
22     }
size() const23     inline size_t size() const {
24         return mTotalSize;
25     }
26 
27     bool merge(AutoStorage<uint8_t>& buffer);
28 
29 private:
30     std::vector<std::pair<size_t, void*>> mBlocks;
31     FILE* mFile                 = nullptr;
32     static const int gCacheSize = 4096;
33     size_t mTotalSize           = 0;
34 };
35 } // namespace MNN
36