| 1 |
/* |
| 2 |
* dirreader.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
* |
| 16 |
* Unicode support by Jim Park -- 08/23/2007 |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "Platform.h" |
| 20 |
#include "tstring.h" |
| 21 |
#include <set> |
| 22 |
|
| 23 |
class dir_reader { |
| 24 |
public: |
| 25 |
|
| 26 |
typedef std::set<tstring>::const_iterator iterator; |
| 27 |
|
| 28 |
dir_reader(); |
| 29 |
virtual ~dir_reader() {} |
| 30 |
|
| 31 |
virtual void read(const tstring& dir) = 0; |
| 32 |
|
| 33 |
virtual const std::set<tstring>& files(); |
| 34 |
virtual const std::set<tstring>& dirs(); |
| 35 |
|
| 36 |
// dir_reader always excludes . and .. AND the exclude list is private, |
| 37 |
// use this backdoor if you need to match "." |
| 38 |
virtual std::set<tstring>& hack_simpleexcluded() {return m_excluded;} |
| 39 |
|
| 40 |
virtual void exclude(const tstring& spec); |
| 41 |
virtual void exclude(const std::set<tstring>& specs); |
| 42 |
|
| 43 |
static bool matches(const tstring& name, const tstring& spec); |
| 44 |
|
| 45 |
protected: |
| 46 |
|
| 47 |
virtual void add_file(const tstring& file); |
| 48 |
virtual void add_dir(const tstring& dir); |
| 49 |
|
| 50 |
virtual bool is_excluded(const tstring& name) const; |
| 51 |
|
| 52 |
private: |
| 53 |
|
| 54 |
std::set<tstring> m_excluded; |
| 55 |
std::set<tstring> m_wildcard_excluded; |
| 56 |
|
| 57 |
std::set<tstring> m_files; |
| 58 |
std::set<tstring> m_dirs; |
| 59 |
|
| 60 |
}; |
| 61 |
|
| 62 |
dir_reader* new_dir_reader(); |