various bugfixes and such.
also bookmarks, temp song loaderm and undo overhaul with near complete multiplayer, but menu items disabled. i really wish i could split this into multiple commits, but i don't know how to work unreal.
This commit is contained in:
squeaksies
2018-11-07 18:00:46 -08:00
parent ac6475494a
commit 7b6050b843
180 changed files with 3336 additions and 3301 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include "ListCallback.h"
#include "ProgressCallback.h"
#include "PreWindowsApi.h"
#include "AllowWindowsPlatformTypes.h"
#include "AllowWindowsPlatformAtomics.h"
#pragma warning(push)
#pragma warning(disable: 4191)
#pragma warning(disable: 4996)
#ifndef DeleteFile
#define DeleteFile DeleteFileW
#endif
#ifndef MoveFile
#define MoveFile MoveFileW
#endif
#ifndef LoadString
#define LoadString LoadStringW
#endif
#ifndef GetMessage
#define GetMessage GetMessageW
#endif
#include <atlbase.h>
#include <sphelper.h>
#undef DeleteFile
#undef MoveFile
#include "SevenZipCompressor.h"
#include "SevenZipExtractor.h"
#include "SevenZipLister.h"
#include "HideWindowsPlatformAtomics.h"
#include "HideWindowsPlatformTypes.h"
#include "PostWindowsApi.h"
#pragma warning(pop)
// Version of this library
#define SEVENZIP_VERSION L"0.2.0-20160117.1"
#define SEVENZIP_BRANCH L"master"

View File

@@ -0,0 +1,31 @@
#pragma once
#include "Enum.h"
namespace SevenZip
{
struct CompressionFormat
{
enum _Enum
{
Unknown,
SevenZip,
Zip,
GZip,
BZip2,
Rar,
Tar,
Iso,
Cab,
Lzma,
Lzma86
};
typedef intl::EnumerationDefinitionNoStrings _Definition;
typedef intl::EnumerationValue< _Enum, _Definition, Unknown > _Value;
};
typedef CompressionFormat::_Value CompressionFormatEnum;
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "Enum.h"
namespace SevenZip
{
struct CompressionLevel
{
enum _Enum
{
None,
Fast,
Normal
};
typedef intl::EnumerationDefinitionNoStrings _Definition;
typedef intl::EnumerationValue< _Enum, _Definition, Normal > _Value;
};
typedef CompressionLevel::_Value CompressionLevelEnum;
}

View File

@@ -0,0 +1,193 @@
#pragma once
//
// ###### To create an enum call MyType with string support: ######
//
//// MyType.h
//struct MyType
//{
// enum _Enum
// {
// Unknown,
// Foo,
// Bar
// };
//
// struct _Definition : public EnumerationDefinition< _Enum, _Definition > { static StringValue Strings[]; };
// typedef EnumerationValue< _Enum, _Definition, Unknown > _Value;
//};
//
//typedef MyType::_Value MyTypeEnum;
//
//
//// MyType.cpp
//#include "MyType.h"
//
//MyType::_Definition::StringValue MyType::_Definition::Strings[] =
//{
// { MyType::Foo, _T( "Foo" ) },
// { MyType::Bar, _T( "Bar" ) },
// { MyType::Unknown, NULL }
//};
//
//
// ###### To create an enum call MyType without string support: ######
//
//// MyType.h
//struct MyType
//{
// enum _Enum
// {
// Unknown,
// Foo,
// Bar
// };
//
// typedef EnumerationDefinitionNoStrings _Definition;
// typedef EnumerationValue< _Enum, _Definition, Unknown > _Value;
//};
//
//typedef MyType::_Value MyTypeEnum;
//
namespace SevenZip
{
namespace intl
{
template < typename TEnum, class DerivedDef >
struct EnumerationDefinition
{
struct StringValue
{
TEnum value;
const TCHAR* string;
};
static TEnum Parse( const TString& string, const TEnum defaultValue )
{
const StringValue* it = DerivedDef::Strings;
for (; it->string != NULL; ++it )
{
if ( string.Compare( it->string ) == 0 )
{
return it->value;
}
}
return defaultValue;
}
static TString Format( const TEnum& value )
{
const StringValue* it = DerivedDef::Strings;
for (; it->string != NULL; ++it )
{
if ( value == it->value )
{
return it->string;
}
}
return TString();
}
};
struct EnumerationDefinitionNoStrings {};
template < typename TEnum, class TEnumClass, TEnum DefaultValue >
class EnumerationValue
{
private:
typedef typename EnumerationValue< TEnum, TEnumClass, DefaultValue > ThisClass;
TEnum m_value;
public:
typedef typename TEnum Enum;
EnumerationValue():
m_value( DefaultValue )
{}
EnumerationValue( const TEnum& value ):
m_value( value )
{}
static ThisClass Parse( const TString& string )
{
return ThisClass( TEnumClass::Parse( string, DefaultValue ) );
}
const TEnum& GetValue() const
{
return m_value;
}
TString GetString() const
{
return TEnumClass::Format( m_value );
}
operator TEnum() const
{
return m_value;
}
ThisClass& operator=( const TEnum& value )
{
m_value = value;
return *this;
}
bool operator==( const ThisClass& that ) const
{
return that.m_value == m_value;
}
bool operator!=( const ThisClass& that ) const
{
return !operator==( that );
}
bool operator==( const TEnum& value ) const
{
return value == m_value;
}
bool operator!=( const TEnum& value ) const
{
return !operator==( value );
}
bool operator< ( const ThisClass& that ) const
{
return m_value < that.m_value;
}
// Bit field members
void AddFlag( const TEnum& value )
{
*reinterpret_cast< int* >( &m_value ) |= static_cast< int >( value );
}
void RemoveFlag( const TEnum& value )
{
*reinterpret_cast< int* >( &m_value ) &= ~static_cast< int >( value );
}
bool HasFlag( const TEnum& value ) const
{
return ( m_value & value ) == value;
}
bool HasAnyFlag( const TEnum& valueCombo ) const
{
return ( m_value & valueCombo ) != 0;
}
};
}
}

View File

@@ -0,0 +1,24 @@
#pragma once
namespace SevenZip
{
namespace intl
{
struct FileInfo
{
TString FileName;
FILETIME LastWriteTime;
FILETIME CreationTime;
FILETIME LastAccessTime;
ULONGLONG Size;
UINT Attributes;
bool IsDirectory;
};
struct FilePathInfo : public FileInfo
{
TString FilePath;
};
}
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "SevenZipLibrary.h"
#include "CompressionFormat.h"
namespace SevenZip
{
class ListCallback
{
public:
/*
Called for each file found in the archive. Size in bytes.
*/
virtual void OnFileFound(const TString& archivePath, const TString& filePath, int size) {}
/*
Called when all the files have been listed
*/
virtual void OnListingDone(const TString& archivePath) {}
};
}

View File

@@ -0,0 +1,40 @@
#pragma once
#include "SevenZipLibrary.h"
#include "CompressionFormat.h"
namespace SevenZip
{
class ProgressCallback
{
public:
/*
Called at beginning
*/
virtual void OnStartWithTotal(const TString& archivePath, unsigned __int64 totalBytes) = 0;
/*
Called Whenever progress has updated with a bytes complete
*/
virtual void OnProgress(const TString& archivePath, unsigned __int64 bytesCompleted) = 0;
/*
Called When progress has reached 100%
*/
virtual void OnDone(const TString& archivePath) = 0;
/*
Called When single file progress has reached 100%, returns the filepath that completed
*/
virtual void OnFileDone(const TString& archivePath, const TString& filePath, unsigned __int64 bytesCompleted) = 0;
/*
Called to determine if it's time to abort the zip operation. Return true to abort the current operation.
*/
virtual bool OnCheckBreak() = 0;
};
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include <tchar.h>
#include <string>
namespace SevenZip
{
#ifdef _UNICODE
typedef std::wstring TString;
#else
typedef std::string TString;
#endif
}

View File

@@ -0,0 +1,48 @@
#pragma once
#include "SevenZipLibrary.h"
#include <atlbase.h>
#include "FileInfo.h"
#include "CompressionFormat.h"
#include "CompressionLevel.h"
namespace SevenZip
{
class SevenZipArchive
{
public:
SevenZipArchive(const SevenZipLibrary& library, const TString& archivePath);
virtual ~SevenZipArchive();
virtual bool ReadInArchiveMetadata();
virtual void SetCompressionFormat(const CompressionFormatEnum& format);
virtual CompressionFormatEnum GetCompressionFormat();
virtual void SetCompressionLevel(const CompressionLevelEnum& level);
virtual CompressionLevelEnum GetCompressionLevel();
virtual bool DetectCompressionFormat();
virtual size_t GetNumberOfItems();
virtual std::vector<TString> GetItemsNames();
virtual std::vector<size_t> GetOrigSizes();
protected:
bool m_ReadMetadata = false;
bool m_OverrideCompressionFormat = false;
const SevenZipLibrary& m_library;
TString m_archivePath;
CompressionFormatEnum m_compressionFormat;
CompressionLevelEnum m_compressionLevel;
size_t m_numberofitems = 0;
std::vector<TString> m_itemnames;
std::vector<size_t> m_origsizes;
private:
bool pri_GetNumberOfItems();
bool pri_GetItemsNames();
bool pri_DetectCompressionFormat(CompressionFormatEnum & format);
bool pri_DetectCompressionFormat();
};
}

View File

@@ -0,0 +1,43 @@
#pragma once
#include <vector>
#include <atlbase.h>
#include "SevenZipLibrary.h"
#include "SevenZipArchive.h"
#include "FileInfo.h"
#include "CompressionFormat.h"
#include "CompressionLevel.h"
#include "ProgressCallback.h"
namespace SevenZip
{
class SevenZipCompressor : public SevenZipArchive
{
public:
SevenZipCompressor( const SevenZipLibrary& library, const TString& archivePath );
virtual ~SevenZipCompressor();
// Includes the last directory as the root in the archive, e.g. specifying "C:\Temp\MyFolder"
// makes "MyFolder" the single root item in archive with the files within it included.
virtual bool CompressDirectory( const TString& directory, ProgressCallback* callback, bool includeSubdirs = true);
// Excludes the last directory as the root in the archive, its contents are at root instead. E.g.
// specifying "C:\Temp\MyFolder" make the files in "MyFolder" the root items in the archive.
virtual bool CompressFiles( const TString& directory, const TString& searchFilter, ProgressCallback* callback, bool includeSubdirs = true );
virtual bool CompressAllFiles( const TString& directory, ProgressCallback* callback, bool includeSubdirs = true );
// Compress just this single file as the root item in the archive.
virtual bool CompressFile( const TString& filePath, ProgressCallback* callback);
private:
TString m_outputPath; //the final compression result compression path. Used for tracking in callbacks
CComPtr< IStream > OpenArchiveStream();
bool FindAndCompressFiles( const TString& directory, const TString& searchPattern,
const TString& pathPrefix, bool recursion, ProgressCallback* callback);
bool CompressFilesToArchive(const TString& pathPrefix, const std::vector< intl::FilePathInfo >& filePaths, ProgressCallback* callback);
bool SetCompressionProperties( IUnknown* outArchive );
};
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include <exception>
#include "SevenString.h"
#include "AllowWindowsPlatformTypes.h"
namespace SevenZip
{
TString StrFmt(const TCHAR* format, ...);
TString GetWinErrMsg(const TString& contextMessage, DWORD lastError);
TString GetCOMErrMsg(const TString& contextMessage, HRESULT lastError);
class SevenZipException
{
protected:
TString m_message;
public:
SevenZipException();
SevenZipException(const TString& message);
virtual ~SevenZipException();
const TString& GetMessage() const;
};
}
#include "HideWindowsPlatformTypes.h"

View File

@@ -0,0 +1,25 @@
#pragma once
#include "SevenZipLibrary.h"
#include "SevenZipArchive.h"
#include "CompressionFormat.h"
#include "ProgressCallback.h"
namespace SevenZip
{
class SevenZipExtractor : public SevenZipArchive
{
public:
SevenZipExtractor( const SevenZipLibrary& library, const TString& archivePath );
virtual ~SevenZipExtractor();
virtual bool ExtractArchive(const TString& directory, ProgressCallback* callback);
virtual bool ExtractFilesFromArchive(const unsigned int* fileIndices, const unsigned int numberFiles, const TString& directory, ProgressCallback* callback);
private:
bool ExtractFilesFromArchive(const CComPtr< IStream >& archiveStream, const unsigned int* fileIndices, const unsigned int numberFiles, const TString& directory, ProgressCallback* callback);
};
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "SevenZipException.h"
#include "CompressionFormat.h"
namespace SevenZip
{
class SevenZipLibrary
{
private:
typedef UINT32 (WINAPI * CreateObjectFunc)( const GUID* clsID, const GUID* interfaceID, void** outObject );
HMODULE m_dll;
CreateObjectFunc m_func;
public:
SevenZipLibrary();
~SevenZipLibrary();
bool Load();
bool Load( const TString& libraryPath );
void Free();
bool CreateObject( const GUID& clsID, const GUID& interfaceID, void** outObject ) const;
};
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include "SevenZipLibrary.h"
#include "SevenZipArchive.h"
#include "CompressionFormat.h"
#include "ListCallback.h"
namespace SevenZip
{
class SevenZipLister : public SevenZipArchive
{
public:
TString m_archivePath;
SevenZipLister( const SevenZipLibrary& library, const TString& archivePath );
virtual ~SevenZipLister();
virtual bool ListArchive(ListCallback* callback);
private:
bool ListArchive(const CComPtr< IStream >& archiveStream, ListCallback* callback);
};
}

View File

@@ -0,0 +1,56 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2015 Igor Pavlov.
Licenses for files are:
1) 7z.dll: GNU LGPL + unRAR restriction
2) 7za.dll: GNU LGPL
The GNU LGPL + unRAR restriction means that you must follow both
GNU LGPL rules and unRAR restriction rules.
Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library 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 2.1 of the License, or (at your option) any later version.
This library 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 can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
unRAR restriction
-----------------
The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.
The license for original unRAR code has the following restriction:
The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.
--
Igor Pavlov