~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to ext/native/file/zip_read.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// TODO: Move much of this code to vfs.cpp
 
2
#pragma once
 
3
 
 
4
#ifdef ANDROID
 
5
#include <zip.h>
 
6
#endif
 
7
 
 
8
#include <string.h>
 
9
#include <string>
 
10
 
 
11
#include "base/basictypes.h"
 
12
#include "file/vfs.h"
 
13
#include "file/file_util.h"
 
14
 
 
15
// Direct readers. deallocate using delete [].
 
16
uint8_t *ReadLocalFile(const char *filename, size_t *size);
 
17
 
 
18
class AssetReader {
 
19
public:
 
20
        virtual ~AssetReader() {}
 
21
        // use delete[]
 
22
        virtual uint8_t *ReadAsset(const char *path, size_t *size) = 0;
 
23
        // Filter support is optional but nice to have
 
24
        virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter = 0) = 0;
 
25
        virtual bool GetFileInfo(const char *path, FileInfo *info) = 0;
 
26
        virtual std::string toString() const = 0;
 
27
};
 
28
 
 
29
#ifdef USING_QT_UI
 
30
class AssetsAssetReader : public AssetReader {
 
31
public:
 
32
        AssetsAssetReader() {}
 
33
        ~AssetsAssetReader() {}
 
34
        // use delete[]
 
35
        virtual uint8_t *ReadAsset(const char *path, size_t *size);
 
36
        virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter);
 
37
        virtual bool GetFileInfo(const char *path, FileInfo *info);
 
38
        virtual std::string toString() const {
 
39
                return ":assets/";
 
40
        }
 
41
};
 
42
#endif
 
43
 
 
44
#ifdef ANDROID
 
45
uint8_t *ReadFromZip(zip *archive, const char* filename, size_t *size);
 
46
class ZipAssetReader : public AssetReader {
 
47
public:
 
48
        ZipAssetReader(const char *zip_file, const char *in_zip_path);
 
49
        ~ZipAssetReader();
 
50
        // use delete[]
 
51
        virtual uint8_t *ReadAsset(const char *path, size_t *size);
 
52
        virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter);
 
53
        virtual bool GetFileInfo(const char *path, FileInfo *info);
 
54
        virtual std::string toString() const {
 
55
                return in_zip_path_;
 
56
        }
 
57
 
 
58
private:
 
59
        zip *zip_file_;
 
60
        char in_zip_path_[256];
 
61
};
 
62
#endif
 
63
 
 
64
class DirectoryAssetReader : public AssetReader {
 
65
public:
 
66
        DirectoryAssetReader(const char *path) {
 
67
                strncpy(path_, path, ARRAY_SIZE(path_));
 
68
                path_[ARRAY_SIZE(path_) - 1] = '\0';
 
69
        }
 
70
        // use delete[]
 
71
        virtual uint8_t *ReadAsset(const char *path, size_t *size);
 
72
        virtual bool GetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter);
 
73
        virtual bool GetFileInfo(const char *path, FileInfo *info);
 
74
        virtual std::string toString() const {
 
75
                return path_;
 
76
        }
 
77
 
 
78
private:
 
79
        char path_[512];
 
80
};
 
81