mirror of
https://github.com/koreader/koreader.git
synced 2025-12-24 12:14:05 +01:00
add datastorage module to handle data directory on various platform
On kindle, kobo and pocketbook the data directory is the current running directory but on Android the app is installed in system defined location and users may have no access to that location. The same circumstances should be true for the upcoming Koreader for Ubuntu touch, so the data directory (in which tessdata, dictionaries, global settings, persistant defaults and probably history data are stored) could be stored in another place.
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
local A = require("android")
|
||||
A.dl.library_path = A.dl.library_path .. ":" .. A.dir .. "/libs"
|
||||
|
||||
local ffi = require("ffi")
|
||||
ffi.cdef[[
|
||||
char *getenv(const char *name);
|
||||
int putenv(const char *envvar);
|
||||
]]
|
||||
|
||||
-- check uri of the intent that starts this application
|
||||
local file = A.jni:context(A.app.activity.vm, function(JNI)
|
||||
local uri = JNI:callObjectMethod(
|
||||
@@ -29,6 +35,9 @@ pcall(function() dofile("/sdcard/koreader/patch.lua") end)
|
||||
-- set proper permission for sdcv
|
||||
A.execute("chmod", "755", "./sdcv")
|
||||
|
||||
-- set TESSDATA_PREFIX env var
|
||||
ffi.C.putenv("TESSDATA_PREFIX=/sdcard/koreader/data")
|
||||
|
||||
-- create fake command-line arguments
|
||||
arg = {"-d", file or "/sdcard"}
|
||||
dofile(A.dir.."/reader.lua")
|
||||
|
||||
Reference in New Issue
Block a user