Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
bba12520
There was an error fetching the commit references. Please try again later.
Commit
bba12520
authored
9 years ago
by
archshift
Browse files
Options
Downloads
Patches
Plain Diff
Expose loader helper functions for identifying files.
parent
b3af7aad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/loader/loader.cpp
+13
-13
13 additions, 13 deletions
src/core/loader/loader.cpp
src/core/loader/loader.h
+28
-0
28 additions, 0 deletions
src/core/loader/loader.h
with
41 additions
and
13 deletions
src/core/loader/loader.cpp
+
13
−
13
View file @
bba12520
...
...
@@ -26,12 +26,7 @@ const std::initializer_list<Kernel::AddressMapping> default_address_mappings = {
{
0x1F000000
,
0x600000
,
false
},
// entire VRAM
};
/**
* Identifies the type of a bootable file
* @param file open file
* @return FileType of file
*/
static
FileType
IdentifyFile
(
FileUtil
::
IOFile
&
file
)
{
FileType
IdentifyFile
(
FileUtil
::
IOFile
&
file
)
{
FileType
type
;
#define CHECK_TYPE(loader) \
...
...
@@ -48,12 +43,17 @@ static FileType IdentifyFile(FileUtil::IOFile& file) {
return
FileType
::
Unknown
;
}
/**
* Guess the type of a bootable file from its extension
* @param extension_ String extension of bootable file
* @return FileType of file
*/
static
FileType
GuessFromExtension
(
const
std
::
string
&
extension_
)
{
FileType
IdentifyFile
(
const
std
::
string
&
file_name
)
{
FileUtil
::
IOFile
file
(
file_name
,
"rb"
);
if
(
!
file
.
IsOpen
())
{
LOG_ERROR
(
Loader
,
"Failed to load file %s"
,
file_name
.
c_str
());
return
FileType
::
Unknown
;
}
return
IdentifyFile
(
file
);
}
FileType
GuessFromExtension
(
const
std
::
string
&
extension_
)
{
std
::
string
extension
=
Common
::
ToLower
(
extension_
);
if
(
extension
==
".elf"
||
extension
==
".axf"
)
...
...
@@ -71,7 +71,7 @@ static FileType GuessFromExtension(const std::string& extension_) {
return
FileType
::
Unknown
;
}
static
const
char
*
GetFileTypeString
(
FileType
type
)
{
const
char
*
GetFileTypeString
(
FileType
type
)
{
switch
(
type
)
{
case
FileType
::
CCI
:
return
"NCSD"
;
...
...
This diff is collapsed.
Click to expand it.
src/core/loader/loader.h
+
28
−
0
View file @
bba12520
...
...
@@ -33,6 +33,34 @@ enum class FileType {
THREEDSX
,
//3DSX
};
/**
* Identifies the type of a bootable file based on the magic value in its header.
* @param file open file
* @return FileType of file
*/
FileType
IdentifyFile
(
FileUtil
::
IOFile
&
file
);
/**
* Identifies the type of a bootable file based on the magic value in its header.
* @param file_name path to file
* @return FileType of file. Note: this will return FileType::Unknown if it is unable to determine
* a filetype, and will never return FileType::Error.
*/
FileType
IdentifyFile
(
const
std
::
string
&
file_name
);
/**
* Guess the type of a bootable file from its extension
* @param extension String extension of bootable file
* @return FileType of file. Note: this will return FileType::Unknown if it is unable to determine
* a filetype, and will never return FileType::Error.
*/
FileType
GuessFromExtension
(
const
std
::
string
&
extension_
);
/**
* Convert a FileType into a string which can be displayed to the user.
*/
const
char
*
GetFileTypeString
(
FileType
type
);
/// Return type for functions in Loader namespace
enum
class
ResultStatus
{
Success
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment