Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-chailove
Commits
e13d137c
Verified
Commit
e13d137c
authored
Nov 03, 2018
by
RobLoach
Browse files
Replace filesystem/path.h
parent
5b769652
Changes
7
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
e13d137c
...
...
@@ -7,3 +7,4 @@ node_modules
/package.json
/.bsv
/*.mkv
*.d
Makefile.common
View file @
e13d137c
...
...
@@ -17,9 +17,6 @@ SOURCES_C := $(CORE_DIR)/vendor/semver/semver.c
# random
FLAGS
+=
-I
$(CORE_DIR)
/vendor/random/include
# filesystem
FLAGS
+=
-I
$(CORE_DIR)
/vendor/filesystem
# libretro-common
FLAGS
+=
-I
$(CORE_DIR)
/vendor/libretro-common/include
# Only compile libretro-common when not STATIC_LINKING
...
...
@@ -49,7 +46,7 @@ ifneq ($(STATIC_LINKING), 1)
)
# Ensure the sinc_resampler_neon is available for ARM NEON devices.
OBJECTS
+=
$(CORE_DIR)
/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.o
# MD5
FLAGS
+=
-I
$(CORE_DIR)
/vendor/libretro-common/include
SOURCES_C
+=
$(CORE_DIR)
/vendor/libretro-common/utils/md5.c
...
...
Makefile.libretro
View file @
e13d137c
...
...
@@ -13,6 +13,7 @@ filter_out1 = $(filter-out $(firstword $1),$1)
filter_out2
=
$(
call
filter_out1,
$(
call
filter_out1,
$1
))
unixpath
=
$(
subst
\,
/,
$1
)
unixcygpath
=
/
$(
subst
:,,
$(
call
unixpath,
$1
))
export
DEPSDIR
:=
$(CURDIR)
/
ifeq
($(platform),)
platform
=
unix
...
...
src/love/Types/FileSystem/FileData.cpp
View file @
e13d137c
...
...
@@ -4,7 +4,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "filesystem/path.h"
#include "../../../ChaiLove.h"
...
...
@@ -38,9 +37,8 @@ std::string FileData::getString() {
}
std
::
string
FileData
::
getExtension
()
{
::
filesystem
::
path
p
(
m_filepath
.
c_str
());
std
::
string
extension
(
p
.
extension
());
return
extension
;
ChaiLove
*
app
=
ChaiLove
::
getInstance
();
return
app
->
filesystem
.
getExtension
(
m_filepath
);
}
}
// namespace FileSystem
...
...
src/love/filesystem.cpp
View file @
e13d137c
...
...
@@ -5,7 +5,6 @@
#include "physfs.h"
#include "filesystem.h"
#include "physfsrwops.h"
#include "filesystem/path.h"
#include "../ChaiLove.h"
#include "Types/FileSystem/FileInfo.h"
...
...
@@ -32,8 +31,7 @@ bool filesystem::init(const std::string& file, const void* data) {
}
// Find the parent and extension of the given file.
::
filesystem
::
path
p
(
file
.
c_str
());
std
::
string
extension
(
p
.
extension
());
std
::
string
extension
(
getFileExtension
(
file
));
// Allow loading from an Archive.
if
(
extension
==
"chaigame"
||
extension
==
"chailove"
||
extension
==
"zip"
)
{
...
...
@@ -41,8 +39,7 @@ bool filesystem::init(const std::string& file, const void* data) {
}
// If we are just running the core, load the base path.
::
filesystem
::
path
parent
(
p
.
parent_path
());
std
::
string
parentPath
(
parent
.
str
());
std
::
string
parentPath
(
getParentDirectory
(
file
));
if
(
parentPath
.
empty
())
{
return
mount
(
"."
,
"/"
,
false
);
}
...
...
@@ -51,6 +48,34 @@ bool filesystem::init(const std::string& file, const void* data) {
return
mount
(
parentPath
.
c_str
(),
"/"
,
false
);
}
std
::
string
filesystem
::
getParentDirectory
(
const
std
::
string
&
filepath
)
{
return
filepath
.
substr
(
0
,
filepath
.
find_last_of
(
"/
\\
"
));
}
std
::
string
filesystem
::
getFileExtension
(
const
std
::
string
&
filepath
)
{
size_t
i
=
filepath
.
rfind
(
'.'
,
filepath
.
length
());
if
(
i
!=
std
::
string
::
npos
)
{
return
filepath
.
substr
(
i
+
1
,
filepath
.
length
()
-
i
);
}
return
""
;
}
std
::
string
filesystem
::
getBasename
(
const
std
::
string
&
filepath
)
{
char
sep
=
'/'
;
#ifdef _WIN32
if
(
filepath
.
find
(
'\\'
)
!=
std
::
string
::
npos
)
{
sep
=
'\\'
;
}
#endif
size_t
i
=
filepath
.
rfind
(
sep
,
filepath
.
length
());
if
(
i
!=
std
::
string
::
npos
)
{
return
filepath
.
substr
(
i
+
1
,
filepath
.
length
()
-
i
);
}
return
""
;
}
void
filesystem
::
mountlibretro
()
{
// Mount some of the libretro directories.
const
char
*
system_dir
=
NULL
;
...
...
@@ -60,8 +85,8 @@ void filesystem::mountlibretro() {
if
(
ChaiLove
::
environ_cb
(
RETRO_ENVIRONMENT_GET_LIBRETRO_PATH
,
&
core_dir
)
&&
core_dir
)
{
// Make sure to get the directory of the core.
::
filesystem
::
path
p
(
core_dir
);
mount
(
p
.
parent
_p
ath
().
str
()
,
"/libretro/core"
,
false
);
std
::
string
parentPath
(
getParentDirectory
(
core_dir
)
)
;
mount
(
parent
P
ath
,
"/libretro/core"
,
false
);
}
if
(
ChaiLove
::
environ_cb
(
RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY
,
&
system_dir
)
&&
system_dir
)
{
mount
(
system_dir
,
"/libretro/system"
,
false
);
...
...
src/love/filesystem.h
View file @
e13d137c
...
...
@@ -78,6 +78,10 @@ class filesystem {
*/
int
getSize
(
const
std
::
string
&
file
);
std
::
string
getFileExtension
(
const
std
::
string
&
filepath
);
std
::
string
getBasename
(
const
std
::
string
&
filepath
);
std
::
string
getParentDirectory
(
const
std
::
string
&
filepath
);
/**
* Removes a file or empty directory.
*
...
...
src/love/script.cpp
View file @
e13d137c
#include "script.h"
#include "../ChaiLove.h"
#include <filesystem/path.h>
#include <algorithm>
#ifdef __HAVE_CHAISCRIPT__
...
...
@@ -86,6 +85,7 @@ std::string script::evalString(const std::string& code, const std::string& filen
script
::
script
(
const
std
::
string
&
file
)
{
#ifdef __HAVE_CHAISCRIPT__
ChaiLove
*
app
=
ChaiLove
::
getInstance
();
// ChaiScript Standard Library Additions
// This adds some basic type definitions to ChaiScript.
...
...
@@ -388,18 +388,18 @@ script::script(const std::string& file) {
// Load the desired main.chai file.
if
(
file
.
empty
())
{
// When no content is provided, display a No Game demo.
eval
(
ChaiLove
::
getInstance
()
->
demo
(),
"demo.chai"
);
eval
(
app
->
demo
(),
"demo.chai"
);
mainLoaded
=
true
;
}
else
{
// Load the main.chai file.
::
filesystem
::
path
p
(
file
.
c_str
());
std
::
string
extension
(
p
.
extension
());
loadModuleRequire
(
"conf"
);
std
::
string
extension
(
app
->
filesystem
.
getExtension
(
file
));
if
(
extension
==
"chailove"
||
extension
==
"chaigame"
)
{
mainLoaded
=
loadModuleRequire
(
"main"
);
}
else
{
// Otherwise, load the actual file.
std
::
string
filename
(
p
.
fil
ename
());
std
::
string
filename
(
app
->
filesystem
.
getBas
ename
(
file
));
mainLoaded
=
loadModuleRequire
(
filename
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment