-
-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
77 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
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,51 @@ | ||
/* Copyright (c) 2014-2017 waddlesplash | ||
* Copyright (c) 2013-2021 Jeffrey Pfau | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
#include "LibraryEntry.h" | ||
|
||
#include <mgba/core/library.h> | ||
|
||
using namespace QGBA; | ||
|
||
static inline uint64_t checkHash(size_t filesize, uint32_t crc32) { | ||
return (uint64_t(filesize) << 32) ^ ((crc32 + 1ULL) * (uint32_t(filesize) + 1ULL)); | ||
} | ||
|
||
LibraryEntry::LibraryEntry(const mLibraryEntry* entry) | ||
: base(entry->base) | ||
, filename(entry->filename) | ||
, fullpath(QString("%1/%2").arg(entry->base, entry->filename)) | ||
, title(entry->title) | ||
, internalTitle(entry->internalTitle) | ||
, internalCode(entry->internalCode) | ||
, platform(entry->platform) | ||
, filesize(entry->filesize) | ||
, crc32(entry->crc32) | ||
{ | ||
} | ||
|
||
bool LibraryEntry::isNull() const { | ||
return fullpath.isNull(); | ||
} | ||
|
||
QString LibraryEntry::displayTitle() const { | ||
if (title.isNull()) { | ||
return filename; | ||
} | ||
return title; | ||
} | ||
|
||
bool LibraryEntry::operator==(const LibraryEntry& other) const { | ||
return other.fullpath == fullpath; | ||
} | ||
|
||
uint64_t LibraryEntry::checkHash() const { | ||
return ::checkHash(filesize, crc32); | ||
} | ||
|
||
uint64_t LibraryEntry::checkHash(const mLibraryEntry* entry) { | ||
return ::checkHash(entry->filesize, entry->crc32); | ||
} |
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,47 @@ | ||
/* Copyright (c) 2014-2017 waddlesplash | ||
* Copyright (c) 2013-2021 Jeffrey Pfau | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
#pragma once | ||
|
||
#include <QByteArray> | ||
#include <QList> | ||
#include <QString> | ||
|
||
#include <mgba/core/core.h> | ||
|
||
struct mLibraryEntry; | ||
|
||
namespace QGBA { | ||
|
||
struct LibraryEntry { | ||
LibraryEntry() = default; | ||
LibraryEntry(const LibraryEntry&) = default; | ||
LibraryEntry(LibraryEntry&&) = default; | ||
LibraryEntry(const mLibraryEntry* entry); | ||
|
||
bool isNull() const; | ||
|
||
QString displayTitle() const; | ||
|
||
QString base; | ||
QString filename; | ||
QString fullpath; | ||
QString title; | ||
QByteArray internalTitle; | ||
QByteArray internalCode; | ||
mPlatform platform; | ||
size_t filesize; | ||
uint32_t crc32; | ||
|
||
LibraryEntry& operator=(const LibraryEntry&) = default; | ||
LibraryEntry& operator=(LibraryEntry&&) = default; | ||
bool operator==(const LibraryEntry& other) const; | ||
|
||
uint64_t checkHash() const; | ||
static uint64_t checkHash(const mLibraryEntry* entry); | ||
}; | ||
|
||
}; |
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