2015-04-19 04:18:49 +00:00
|
|
|
/*
|
2018-09-02 00:57:29 +00:00
|
|
|
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
|
2015-04-19 04:18:49 +00:00
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <physfs.h>
|
|
|
|
|
|
|
|
typedef char file_extension_t[5];
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
2015-04-26 20:15:51 +00:00
|
|
|
#include "null_sentinel_iterator.h"
|
|
|
|
|
2015-04-19 04:18:49 +00:00
|
|
|
#include "dxxsconf.h"
|
2016-03-19 19:08:10 +00:00
|
|
|
#include "dsx-ns.h"
|
2016-08-06 19:55:23 +00:00
|
|
|
#include "fwd-partial_range.h"
|
2020-05-02 21:18:42 +00:00
|
|
|
#include <array>
|
2015-04-19 04:18:49 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-13 18:00:48 +00:00
|
|
|
|
2015-04-19 04:18:49 +00:00
|
|
|
class PHYSFS_list_deleter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void operator()(char **list) const
|
|
|
|
{
|
|
|
|
PHYSFS_freeList(list);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename D>
|
2015-05-09 17:38:57 +00:00
|
|
|
class PHYSFSX_uncounted_list_template : public std::unique_ptr<char *[], D>
|
2015-04-19 04:18:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-04-26 20:15:51 +00:00
|
|
|
typedef null_sentinel_iterator<char *> const_iterator;
|
2016-09-11 18:49:13 +00:00
|
|
|
DXX_INHERIT_CONSTRUCTORS(PHYSFSX_uncounted_list_template, std::unique_ptr<char *[], D>);
|
2015-04-26 20:15:51 +00:00
|
|
|
const_iterator begin() const
|
|
|
|
{
|
|
|
|
return this->get();
|
|
|
|
}
|
|
|
|
const_iterator end() const
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
2015-04-19 04:18:49 +00:00
|
|
|
};
|
|
|
|
|
2015-05-09 17:38:57 +00:00
|
|
|
template <typename D>
|
|
|
|
class PHYSFSX_counted_list_template : public PHYSFSX_uncounted_list_template<D>
|
|
|
|
{
|
|
|
|
typedef PHYSFSX_uncounted_list_template<D> base_ptr;
|
2017-08-11 23:43:54 +00:00
|
|
|
using typename base_ptr::pointer;
|
2019-04-28 00:53:40 +00:00
|
|
|
uint_fast32_t count = 0;
|
2015-05-09 17:38:57 +00:00
|
|
|
public:
|
2019-04-28 00:53:40 +00:00
|
|
|
using base_ptr::base_ptr;
|
2015-05-09 17:38:57 +00:00
|
|
|
uint_fast32_t get_count() const
|
|
|
|
{
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
void set_count(uint_fast32_t c)
|
|
|
|
{
|
|
|
|
count = c;
|
|
|
|
}
|
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
base_ptr::reset();
|
|
|
|
}
|
|
|
|
void reset(pointer p)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
base_ptr::reset(p);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef PHYSFSX_uncounted_list_template<PHYSFS_list_deleter> PHYSFSX_uncounted_list;
|
|
|
|
typedef PHYSFSX_counted_list_template<PHYSFS_list_deleter> PHYSFSX_counted_list;
|
2015-04-19 04:18:49 +00:00
|
|
|
|
2021-06-28 03:37:51 +00:00
|
|
|
[[nodiscard]]
|
2015-04-19 04:18:49 +00:00
|
|
|
__attribute_nonnull()
|
2016-01-29 04:05:47 +00:00
|
|
|
PHYSFSX_uncounted_list PHYSFSX_findFiles(const char *path, partial_range_t<const file_extension_t *> exts);
|
2015-04-19 04:18:49 +00:00
|
|
|
|
2021-06-28 03:37:51 +00:00
|
|
|
[[nodiscard]]
|
2015-04-19 04:18:49 +00:00
|
|
|
__attribute_nonnull()
|
2016-01-29 04:05:47 +00:00
|
|
|
PHYSFSX_uncounted_list PHYSFSX_findabsoluteFiles(const char *path, const char *realpath, const partial_range_t<const file_extension_t *> exts);
|
2015-12-13 18:00:48 +00:00
|
|
|
|
|
|
|
}
|
2015-04-19 04:18:49 +00:00
|
|
|
#endif
|