增加内外storage的读取
This commit is contained in:
parent
cb54fd021e
commit
a5d459fe3f
@ -459,6 +459,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual std::string getWritablePath() const = 0;
|
virtual std::string getWritablePath() const = 0;
|
||||||
|
|
||||||
|
virtual std::string getExtFileDirectory() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets writable path.
|
* Sets writable path.
|
||||||
*/
|
*/
|
||||||
|
@ -328,6 +328,25 @@ std::string FileUtilsAndroid::getWritablePath() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string FileUtilsAndroid::getExtFileDirectory() const
|
||||||
|
{
|
||||||
|
// Fix for Nexus 10 (Android 4.2 multi-user environment)
|
||||||
|
// the path is retrieved through Java Context.getCacheDir() method
|
||||||
|
std::string dir("");
|
||||||
|
std::string tmp = JniHelper::callStaticStringMethod(JCLS_HELPER, "getExtFileDirectory");
|
||||||
|
|
||||||
|
if (tmp.length() > 0)
|
||||||
|
{
|
||||||
|
dir.append(tmp).append("/");
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
virtual FileUtils::Status getContents(const std::string& filename, ResizableBuffer* buffer) override;
|
virtual FileUtils::Status getContents(const std::string& filename, ResizableBuffer* buffer) override;
|
||||||
|
|
||||||
virtual std::string getWritablePath() const override;
|
virtual std::string getWritablePath() const override;
|
||||||
|
virtual std::string getExtFileDirectory() const override;
|
||||||
virtual bool isAbsolutePath(const std::string& strPath) const override;
|
virtual bool isAbsolutePath(const std::string& strPath) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -83,6 +83,7 @@ public class Cocos2dxHelper {
|
|||||||
private static boolean sActivityVisible;
|
private static boolean sActivityVisible;
|
||||||
private static String sPackageName;
|
private static String sPackageName;
|
||||||
private static String sFileDirectory;
|
private static String sFileDirectory;
|
||||||
|
private static String sExtFileDirectory;
|
||||||
private static Activity sActivity = null;
|
private static Activity sActivity = null;
|
||||||
private static Cocos2dxHelperListener sCocos2dxHelperListener;
|
private static Cocos2dxHelperListener sCocos2dxHelperListener;
|
||||||
private static Set<OnActivityResultListener> onActivityResultListeners = new LinkedHashSet<OnActivityResultListener>();
|
private static Set<OnActivityResultListener> onActivityResultListeners = new LinkedHashSet<OnActivityResultListener>();
|
||||||
@ -205,8 +206,8 @@ public class Cocos2dxHelper {
|
|||||||
final ApplicationInfo applicationInfo = activity.getApplicationInfo();
|
final ApplicationInfo applicationInfo = activity.getApplicationInfo();
|
||||||
|
|
||||||
Cocos2dxHelper.sPackageName = applicationInfo.packageName;
|
Cocos2dxHelper.sPackageName = applicationInfo.packageName;
|
||||||
Cocos2dxHelper.sFileDirectory = activity.getExternalFilesDir("luaframework").getAbsolutePath();
|
Cocos2dxHelper.sExtFileDirectory = activity.getExternalFilesDir(null).getAbsolutePath();
|
||||||
// Cocos2dxHelper.sFileDirectory = activity.getFilesDir().getAbsolutePath();
|
Cocos2dxHelper.sFileDirectory = activity.getFilesDir().getAbsolutePath();
|
||||||
|
|
||||||
Cocos2dxHelper.nativeSetApkPath(Cocos2dxHelper.getAssetsPath());
|
Cocos2dxHelper.nativeSetApkPath(Cocos2dxHelper.getAssetsPath());
|
||||||
|
|
||||||
@ -300,6 +301,9 @@ public class Cocos2dxHelper {
|
|||||||
public static String getWritablePath() {
|
public static String getWritablePath() {
|
||||||
return Cocos2dxHelper.sFileDirectory;
|
return Cocos2dxHelper.sFileDirectory;
|
||||||
}
|
}
|
||||||
|
public static String getExtFileDirectory() {
|
||||||
|
return Cocos2dxHelper.sExtFileDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getCurrentLanguage() {
|
public static String getCurrentLanguage() {
|
||||||
return Locale.getDefault().getLanguage();
|
return Locale.getDefault().getLanguage();
|
||||||
|
@ -232,7 +232,11 @@ void jsb_init_file_operation_delegate()
|
|||||||
se::ScriptEngine::getInstance()->setFileOperationDelegate(delegate);
|
se::ScriptEngine::getInstance()->setFileOperationDelegate(delegate);
|
||||||
}
|
}
|
||||||
std::string path = FileUtils::getInstance()->getWritablePath();
|
std::string path = FileUtils::getInstance()->getWritablePath();
|
||||||
|
std::string extPath = FileUtils::getInstance()->getExtFileDirectory();
|
||||||
|
extPath += "luaframework/";
|
||||||
|
path += "luaframework/";
|
||||||
std::vector<std::string> searchPaths;
|
std::vector<std::string> searchPaths;
|
||||||
|
searchPaths.push_back(extPath);
|
||||||
searchPaths.push_back(path);
|
searchPaths.push_back(path);
|
||||||
searchPaths.push_back("");
|
searchPaths.push_back("");
|
||||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user