Skip to content

Commit

Permalink
Merge branch 'archive_refactor'
Browse files Browse the repository at this point in the history
# Conflicts:
#	tools/xcode/DarkRadiant.xcodeproj/project.pbxproj
  • Loading branch information
codereader committed Sep 11, 2017
2 parents e55c655 + 98e0883 commit babb967
Show file tree
Hide file tree
Showing 54 changed files with 1,590 additions and 1,574 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Expand Up @@ -48,6 +48,9 @@ AC_PROG_LIBTOOL
# We require a C++11-compliant compiler, without nonstandard extensions
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])

# We require the cstdint header to be present
AC_CHECK_HEADER([cstdint], [], [AC_MSG_ERROR([Could not find the <cstdint> header.])])

# Optional features
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
Expand Down
58 changes: 58 additions & 0 deletions libs/DirectoryArchiveFile.h
@@ -0,0 +1,58 @@
#pragma once

#include "iarchive.h"
#include "stream/FileInputStream.h"

namespace archive
{

/// \brief An ArchiveFile which is stored as a single file on disk.
class DirectoryArchiveFile :
public ArchiveFile
{
private:
std::string _name;
stream::FileInputStream _istream;
stream::FileInputStream::size_type _size;

public:
typedef stream::FileInputStream::size_type size_type;

DirectoryArchiveFile(const std::string& name, const std::string& filename) :
_name(name),
_istream(filename)
{
if (!failed())
{
_istream.seek(0, stream::FileInputStream::end);
_size = _istream.tell();
_istream.seek(0);
}
else
{
_size = 0;
}
}

bool failed() const
{
return _istream.failed();
}

size_type size() const override
{
return _size;
}

const std::string& getName() const override
{
return _name;
}

InputStream& getInputStream() override
{
return _istream;
}
};

}
54 changes: 54 additions & 0 deletions libs/DirectoryArchiveTextFile.h
@@ -0,0 +1,54 @@
#pragma once

#include "iarchive.h"
#include "stream/TextFileInputStream.h"

namespace archive
{

/// \brief An ArchiveTextFile which is stored as a single file on disk.
class DirectoryArchiveTextFile :
public ArchiveTextFile
{
private:
std::string _name;
TextFileInputStream _inputStream;

// Mod directory
std::string _modName;

public:

DirectoryArchiveTextFile(const std::string& name,
const std::string& modName,
const std::string& filename) :
_name(name),
_inputStream(filename),
_modName(modName)
{}

bool failed() const
{
return _inputStream.failed();
}

const std::string& getName() const override
{
return _name;
}

TextInputStream& getInputStream() override
{
return _inputStream;
}

/**
* Get mod directory.
*/
std::string getModName() const override
{
return _modName;
}
};

}
250 changes: 0 additions & 250 deletions libs/archivelib.h

This file was deleted.

0 comments on commit babb967

Please sign in to comment.