add access

This commit is contained in:
AloneMonkey 2017-12-12 19:48:06 +08:00
parent dbe5f0c0e3
commit d58aeeec01
1 changed files with 5 additions and 1 deletions

View File

@ -134,6 +134,7 @@ write = getExportFunction("f", "write", "int", ["int", "pointer", "int"]);
lseek = getExportFunction("f", "lseek", "int64", ["int", "int64", "int"]); lseek = getExportFunction("f", "lseek", "int64", ["int", "int64", "int"]);
close = getExportFunction("f", "close", "int", ["int"]); close = getExportFunction("f", "close", "int", ["int"]);
remove = getExportFunction("f", "remove", "int", ["pointer"]); remove = getExportFunction("f", "remove", "int", ["pointer"]);
access = getExportFunction("f", "access", "int", ["pointer", "int"]);
function getDocumentDir() { function getDocumentDir() {
var NSDocumentDirectory = 9; var NSDocumentDirectory = 9;
@ -209,7 +210,10 @@ function dumpModule(name) {
var newmodpath = getDocumentDir() + "/" + newmodname; var newmodpath = getDocumentDir() + "/" + newmodname;
var oldmodpath = modules[i].path; var oldmodpath = modules[i].path;
remove(allocStr(newmodpath));
if(!access(allocStr(newmodpath),0)){
remove(allocStr(newmodpath));
}
var fmodule = open(newmodpath, O_CREAT | O_RDWR, 0); var fmodule = open(newmodpath, O_CREAT | O_RDWR, 0);
var foldmodule = open(oldmodpath, O_RDONLY, 0); var foldmodule = open(oldmodpath, O_RDONLY, 0);