V-Gears 0
Free Final Fantasy VII engine.
VGearsLGPArchive.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreArchive.h>
19#include "common/TypeDefine.h"
20
21namespace VGears{
22
26 class LGPArchive : public Ogre::Archive{
27
28 public:
29
36 LGPArchive(const String &name, const String &arch_type);
37
41 virtual ~LGPArchive();
42
48 bool isCaseSensitive() const{return true;}
49
53 void load();
54
58 void unload();
59
67 Ogre::DataStreamPtr open(
68 const String& filename, bool readOnly = true
69 ) const;
70
78 Ogre::DataStreamPtr create(const String& filename) const;
79
87 void remove(const String& filename) const;
88
99 Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false) const;
100
111 Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) const;
112
126 Ogre::StringVectorPtr find(
127 const String& pattern, bool recursive = true, bool dirs = false
128 ) const;
129
143 Ogre::FileInfoListPtr findFileInfo(
144 const String& pattern, bool recursive = true, bool dirs = false
145 ) const;
146
153 bool exists(const String& filename) const;
154
161 time_t getModifiedTime(const String& filename) const;
162
166 struct FileEntry{
167
172
177
182
187
192
197
202 };
203
204 typedef std::vector<FileEntry> FileList;
205
211 virtual FileList& GetFiles();
212
213 protected:
214
220 void Load(Ogre::DataStream* lgp);
221
222 private:
223
228
232 Ogre::DataStreamPtr lgp_file_;
233
237 Ogre::FileInfoList file_infos_;
238 };
239}
Handles LZS compressed archives.
Definition: VGearsLGPArchive.h:26
bool exists(const String &filename) const
Checks if the named file exists.
Definition: VGearsLGPArchive.cpp:181
FileList files_
List of file sin the archive.
Definition: VGearsLGPArchive.h:227
std::vector< FileEntry > FileList
Definition: VGearsLGPArchive.h:204
void remove(const String &filename) const
Deletes a named file.
Definition: VGearsLGPArchive.cpp:104
Ogre::DataStreamPtr lgp_file_
The LGP archive file.
Definition: VGearsLGPArchive.h:232
virtual ~LGPArchive()
Destructor.
Definition: VGearsLGPArchive.cpp:29
Ogre::FileInfoList file_infos_
List of information blocks about about the files in the LGP.
Definition: VGearsLGPArchive.h:237
void unload()
Unloads the archive.
Definition: VGearsLGPArchive.cpp:64
LGPArchive(const String &name, const String &arch_type)
Constructor.
Definition: VGearsLGPArchive.cpp:26
void load()
Loads the archive.
Definition: VGearsLGPArchive.cpp:31
Ogre::StringVectorPtr find(const String &pattern, bool recursive=true, bool dirs=false) const
Finds all file or directory names matching a given pattern in the archive.
Definition: VGearsLGPArchive.cpp:137
void Load(Ogre::DataStream *lgp)
Loads a LGP archive.
Definition: VGearsLGPArchive.cpp:40
virtual FileList & GetFiles()
Retrieves the files in the archive.
Definition: VGearsLGPArchive.cpp:202
Ogre::DataStreamPtr open(const String &filename, bool readOnly=true) const
Opens a stream on a LGP compressed file.
Definition: VGearsLGPArchive.cpp:71
Ogre::StringVectorPtr list(bool recursive=true, bool dirs=false) const
Lists all file names in the archive.
Definition: VGearsLGPArchive.cpp:112
time_t getModifiedTime(const String &filename) const
Retrieve the modification time of a given file.
Definition: VGearsLGPArchive.cpp:195
Ogre::FileInfoListPtr listFileInfo(bool recursive=true, bool dirs=false) const
Lists all files in the archive with accompanying information.
Definition: VGearsLGPArchive.cpp:126
Ogre::DataStreamPtr create(const String &filename) const
Creates a new file (or overwrite one already there).
Definition: VGearsLGPArchive.cpp:96
Ogre::FileInfoListPtr findFileInfo(const String &pattern, bool recursive=true, bool dirs=false) const
Finds all files or directories matching a given pattern in this archive and get some detailed informa...
Definition: VGearsLGPArchive.cpp:157
bool isCaseSensitive() const
Checks whether this archive is case sensitive.
Definition: VGearsLGPArchive.h:48
Definition: FF7NameLookup.h:24
Ogre::uint16 uint16
Definition: TypeDefine.h:32
Ogre::String String
Definition: TypeDefine.h:37
Ogre::uint32 uint32
Definition: TypeDefine.h:33
Ogre::uint8 uint8
Definition: TypeDefine.h:31
A file in a LGP archive.
Definition: VGearsLGPArchive.h:166
uint8 unknown1
Unknown data.
Definition: VGearsLGPArchive.h:181
uint32 file_offset
The file offset from the beginning of the archive.
Definition: VGearsLGPArchive.h:176
String file_name
The file name.
Definition: VGearsLGPArchive.h:171
uint32 data_offset
Data offset.
Definition: VGearsLGPArchive.h:201
String datafile_name
NAme of the data file.
Definition: VGearsLGPArchive.h:191
uint32 data_size
Size of the data, in bytes.
Definition: VGearsLGPArchive.h:196
uint16 unknown2
Unknown data.
Definition: VGearsLGPArchive.h:186