| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef AAPT_IO_FILESYSTEM_H |
| 18 |
#define AAPT_IO_FILESYSTEM_H |
| 19 |
|
| 20 |
#include <map> |
| 21 |
|
| 22 |
#include "io/File.h" |
| 23 |
|
| 24 |
namespace aapt { |
| 25 |
namespace io { |
| 26 |
|
| 27 |
|
| 28 |
class RegularFile : public IFile { |
| 29 |
public: |
| 30 |
explicit RegularFile(const Source& source); |
| 31 |
|
| 32 |
std::unique_ptr<IData> OpenAsData() override; |
| 33 |
std::unique_ptr<io::InputStream> OpenInputStream() override; |
| 34 |
const Source& GetSource() const override; |
| 35 |
|
| 36 |
private: |
| 37 |
DISALLOW_COPY_AND_ASSIGN(RegularFile); |
| 38 |
|
| 39 |
Source source_; |
| 40 |
}; |
| 41 |
|
| 42 |
class FileCollection; |
| 43 |
|
| 44 |
class FileCollectionIterator : public IFileCollectionIterator { |
| 45 |
public: |
| 46 |
explicit FileCollectionIterator(FileCollection* collection); |
| 47 |
|
| 48 |
bool HasNext() override; |
| 49 |
io::IFile* Next() override; |
| 50 |
|
| 51 |
private: |
| 52 |
DISALLOW_COPY_AND_ASSIGN(FileCollectionIterator); |
| 53 |
|
| 54 |
std::map<std::string, std::unique_ptr<IFile>>::const_iterator current_, end_; |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
class FileCollection : public IFileCollection { |
| 59 |
public: |
| 60 |
FileCollection() = default; |
| 61 |
|
| 62 |
|
| 63 |
static std::unique_ptr<FileCollection> Create(const android::StringPiece& path, |
| 64 |
std::string* outError); |
| 65 |
|
| 66 |
|
| 67 |
IFile* InsertFile(const android::StringPiece& path); |
| 68 |
IFile* FindFile(const android::StringPiece& path) override; |
| 69 |
std::unique_ptr<IFileCollectionIterator> Iterator() override; |
| 70 |
char GetDirSeparator() override; |
| 71 |
|
| 72 |
private: |
| 73 |
DISALLOW_COPY_AND_ASSIGN(FileCollection); |
| 74 |
|
| 75 |
friend class FileCollectionIterator; |
| 76 |
|
| 77 |
std::map<std::string, std::unique_ptr<IFile>> files_; |
| 78 |
}; |
| 79 |
|
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
#endif |