Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move StoredArchive[Text]File classes to separate files.
- Loading branch information
1 parent
42ad416
commit d47ba92
Showing
7 changed files
with
137 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "iarchive.h" | ||
#include "archivelib.h" | ||
|
||
namespace archive | ||
{ | ||
|
||
/// \brief An ArchiveFile which is stored uncompressed as part of a larger archive file. | ||
class StoredArchiveFile : | ||
public ArchiveFile | ||
{ | ||
private: | ||
std::string _name; | ||
FileInputStream _filestream; | ||
SubFileInputStream _substream; // provides a subset of _filestream | ||
FileInputStream::size_type _size; | ||
|
||
public: | ||
typedef FileInputStream::size_type size_type; | ||
typedef FileInputStream::position_type position_type; | ||
|
||
StoredArchiveFile(const std::string& name, | ||
const std::string& archiveName, // full path to the archive file | ||
position_type position, | ||
size_type stream_size, | ||
size_type file_size) : | ||
_name(name), | ||
_filestream(archiveName), | ||
_substream(_filestream, position, stream_size), | ||
_size(file_size) | ||
{} | ||
|
||
size_type size() const override | ||
{ | ||
return _size; | ||
} | ||
|
||
const std::string& getName() const override | ||
{ | ||
return _name; | ||
} | ||
|
||
InputStream& getInputStream() override | ||
{ | ||
return _substream; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include "iarchive.h" | ||
#include "archivelib.h" | ||
|
||
namespace archive | ||
{ | ||
|
||
/// \brief An ArchiveTextFile which is stored uncompressed as part of a larger archive file. | ||
class StoredArchiveTextFile : | ||
public ArchiveTextFile | ||
{ | ||
private: | ||
std::string _name; | ||
FileInputStream _filestream; | ||
SubFileInputStream _substream; // provides a subset of _filestream | ||
BinaryToTextInputStream<SubFileInputStream> _textStream; // converts data from _substream | ||
|
||
// Mod directory | ||
std::string _modName; | ||
public: | ||
typedef FileInputStream::size_type size_type; | ||
typedef FileInputStream::position_type position_type; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param modDir | ||
* Name of the mod directory containing this file. | ||
*/ | ||
StoredArchiveTextFile(const std::string& name, | ||
const std::string& archiveName, | ||
const std::string& modName, | ||
position_type position, | ||
size_type stream_size) : | ||
_name(name), | ||
_filestream(archiveName), | ||
_substream(_filestream, position, stream_size), | ||
_textStream(_substream), | ||
_modName(modName) | ||
{} | ||
|
||
const std::string& getName() const override | ||
{ | ||
return _name; | ||
} | ||
|
||
TextInputStream& getInputStream() override | ||
{ | ||
return _textStream; | ||
} | ||
|
||
/** | ||
* Return mod directory. | ||
*/ | ||
std::string getModName() const override | ||
{ | ||
return _modName; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters