summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/zippath.h
blob: 1eb92aa1c1d0d432d83b7f4c7718340252daf927 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/***************************************************************************

    zippath.h

    File/directory/path operations that work with ZIP files

***************************************************************************/

#ifndef MAME_LIB_UTIL_ZIPPATH_H
#define MAME_LIB_UTIL_ZIPPATH_H

#pragma once

#include "corefile.h"
#include "unzip.h"

#include <string>
#include <string_view>


namespace util {

/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

class zippath_directory
{
public:
	typedef std::unique_ptr<zippath_directory> ptr;

	// opens a directory
	static osd_file::error open(std::string_view path, ptr &directory);

	// closes a directory
	virtual ~zippath_directory();

	// reads a directory entry
	virtual osd::directory::entry const *readdir() = 0;

	// returns true if this directory is an archive or false if it is a filesystem directory
	virtual bool is_archive() const = 0;
};



/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/

// ----- path operations -----

// retrieves the parent directory
std::string zippath_parent(std::string_view path);

// combines two paths
std::string &zippath_combine(std::string &dst, const std::string &path1, const std::string &path2);
std::string zippath_combine(const std::string &path1, const std::string &path2);


// ----- file operations -----

// opens a zip path file
osd_file::error zippath_fopen(std::string_view filename, uint32_t openflags, util::core_file::ptr &file, std::string &revised_path);

} // namespace util

#endif // MAME_LIB_UTIL_ZIPPATH_H