mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Add support for love.filedropped in Android.
To send file to the filedropped callback, share the files to the game. Note that for non-fused binary, if there's no game running, LOVE treat it as *.love game to run.
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
#include "NativeFile.h"
|
||||
#include "common/utf8.h"
|
||||
|
||||
#ifdef LOVE_ANDROID
|
||||
#include "common/android.h"
|
||||
#endif
|
||||
|
||||
// Assume POSIX or Visual Studio.
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -84,7 +88,22 @@ bool NativeFile::open(Mode newmode)
|
||||
if (file != nullptr)
|
||||
return false;
|
||||
|
||||
#ifdef LOVE_WINDOWS
|
||||
#if defined(LOVE_ANDROID)
|
||||
// Try to handle content:// URI
|
||||
int fd = love::android::getFDFromContentProtocol(filename.c_str());
|
||||
if (fd != -1)
|
||||
{
|
||||
if (newmode != MODE_READ)
|
||||
{
|
||||
::close(fd);
|
||||
throw love::Exception("%s is read-only.", filename.c_str());
|
||||
}
|
||||
|
||||
file = fdopen(fd, "rb");
|
||||
}
|
||||
else
|
||||
file = fopen(filename.c_str(), getModeString(newmode));
|
||||
#elif defined(LOVE_WINDOWS)
|
||||
// make sure non-ASCII filenames work.
|
||||
std::wstring modestr = to_widestr(getModeString(newmode));
|
||||
std::wstring wfilename = to_widestr(filename);
|
||||
|
||||
Reference in New Issue
Block a user