/
archiveentryfile.h
97 lines (80 loc) · 2.8 KB
/
archiveentryfile.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* The Doomsday Engine Project -- libcore
*
* Copyright © 2009-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBDENG2_ARCHIVEENTRYFILE_H
#define LIBDENG2_ARCHIVEENTRYFILE_H
#include "../ByteArrayFile"
namespace de {
class Archive;
class ArchiveFolder;
/**
* Accesses data of an entry within an archive.
*
* @ingroup fs
*/
class ArchiveEntryFile : public ByteArrayFile
{
public:
/**
* Constructs an archive file.
*
* @param name Name of the file.
* @param archive Archive where the contents of the file are located.
* @param entryPath Path of the file's entry within the archive.
*/
ArchiveEntryFile(String const &name, Archive &archive, String const &entryPath);
~ArchiveEntryFile();
String describe() const;
String entryPath() const;
void clear();
/**
* Flushes the entire archive that this file is part of into its source
* file.
*
* Flushing may be needed when one needs to access the source file
* containing the archive while the archive is still present in the tree as
* Files and Folders.
*
* A flush is only done if the archive has been marked as changed. Without
* manual flushing this occurs automatically when the root ArchiveFeed
* instance is deleted.
*/
void flush();
/// Returns the archive of the file.
Archive &archive();
/// Returns the archive of the file (non-modifiable).
Archive const &archive() const;
void uncache() const;
// Implements IByteArray.
Size size() const;
void get(Offset at, Byte *values, Size count) const;
/**
* Modifies the content of an archive entry. Changes are made instantly
* in the source archive, however nothing is written to the source file
* containing the archive until a flush occurs.
*
* @param at Offset where to write to.
* @param values Data.
* @param count Length of data.
*/
void set(Offset at, Byte const *values, Size count);
private:
DENG2_PRIVATE(d)
};
} // namespace de
#endif /* LIBDENG2_ARCHIVEENTRYFILE_H */