mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-24 13:34:44 +00:00
file detection and loader support
This commit is contained in:
parent
3328e82c9c
commit
083c990ca6
6 changed files with 46 additions and 0 deletions
|
@ -9,5 +9,7 @@ Files: CMakeSettings.json
|
|||
.github/shadps4.desktop
|
||||
.github/shadps4.png
|
||||
.gitmodules
|
||||
src/images/shadps4.ico
|
||||
src/shadps4.rc
|
||||
Copyright: shadPS4 Emulator Project
|
||||
License: GPL-2.0-or-later
|
||||
|
|
|
@ -127,6 +127,7 @@ set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
|||
src/Emulator/Host/controller.h
|
||||
)
|
||||
|
||||
# the above is shared in sdl and qt version (TODO share them all)
|
||||
set(COMMON src/common/types.h
|
||||
src/common/endian.h
|
||||
src/common/concepts.h
|
||||
|
@ -134,6 +135,10 @@ set(COMMON src/common/types.h
|
|||
src/common/io_file.h
|
||||
)
|
||||
|
||||
set(CORE src/core/loader.cpp
|
||||
src/core/loader.h
|
||||
)
|
||||
|
||||
set(CRYPTO src/core/crypto/crypto.cpp
|
||||
src/core/crypto/crypto.h
|
||||
src/core/crypto/keys.h
|
||||
|
@ -244,6 +249,7 @@ add_executable(shadps4
|
|||
src/core/tls.cpp
|
||||
src/core/tls.h
|
||||
${COMMON}
|
||||
${CORE}
|
||||
${CRYPTO}
|
||||
${FILE_FORMAT}
|
||||
)
|
||||
|
@ -265,6 +271,10 @@ if (WIN32)
|
|||
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_sources(shadps4 PRIVATE src/shadps4.rc)
|
||||
endif()
|
||||
|
||||
target_include_directories(shadps4 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
|
24
src/core/loader.cpp
Normal file
24
src/core/loader.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/io_file.h"
|
||||
#include "common/types.h"
|
||||
#include "loader.h"
|
||||
|
||||
FileTypes detectFileType(const std::string& filepath) {
|
||||
if (filepath.size() == 0) // no file loaded
|
||||
{
|
||||
return FILETYPE_UNKNOWN;
|
||||
}
|
||||
Common::FS::IOFile file;
|
||||
file.Open(filepath, Common::FS::FileAccessMode::Read);
|
||||
file.Seek(0);
|
||||
u32 magic;
|
||||
file.ReadRaw<u8>(&magic, sizeof(magic));
|
||||
file.Close();
|
||||
switch (magic) {
|
||||
case 0x544e437f: // PS4 PKG
|
||||
return FILETYPE_PKG;
|
||||
}
|
||||
return FILETYPE_UNKNOWN;
|
||||
}
|
9
src/core/loader.h
Normal file
9
src/core/loader.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
enum FileTypes { FILETYPE_UNKNOWN, FILETYPE_PKG };
|
||||
FileTypes detectFileType(const std::string& filepath);
|
BIN
src/images/shadps4.ico
Normal file
BIN
src/images/shadps4.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 KiB |
1
src/shadps4.rc
Normal file
1
src/shadps4.rc
Normal file
|
@ -0,0 +1 @@
|
|||
IDI_ICON1 ICON "images/shadps4.ico"
|
Loading…
Add table
Reference in a new issue