asserts
This commit is contained in:
parent
76d0d54a34
commit
e93c01f8e0
@ -50,12 +50,13 @@ typedef struct {
|
|||||||
} vfs_stat;
|
} vfs_stat;
|
||||||
|
|
||||||
typedef enum vfs_flags {
|
typedef enum vfs_flags {
|
||||||
VFS_CAN_WRITE = 0x1, /// we can write to files in this space
|
VFS_CAN_READ = 0x1, /// we can write to files in this space
|
||||||
VFS_CAN_EXEC = 0x2, /// we can execute files in this space
|
VFS_CAN_WRITE = 0x2, /// we can write to files in this space
|
||||||
VFS_CAN_SEEK = 0x4, /// we can seek within files in this space
|
VFS_CAN_EXEC = 0x4, /// we can execute files in this space
|
||||||
VFS_HAS_PREFIX = 0x8, /// has a prefix that identifies a file in this space
|
VFS_CAN_SEEK = 0x8, /// we can seek within files in this space
|
||||||
VFS_HAS_SUFFIX = 0x10, /// has a suffix that describes the file.
|
VFS_HAS_PREFIX = 0x10, /// has a prefix that identifies a file in this space
|
||||||
VFS_HAS_FUNCTION = 0x20 /// has a suffix that describes the file.
|
VFS_HAS_SUFFIX = 0x20, /// has a suffix that describes the file.
|
||||||
|
VFS_HAS_FUNCTION = 0x40 /// has a suffix that describes the file.
|
||||||
} vfs_flags_t;
|
} vfs_flags_t;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
|
12
os/assets.c
12
os/assets.c
@ -153,7 +153,7 @@ static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out) {
|
|||||||
struct stat bf;
|
struct stat bf;
|
||||||
fname += strlen(me->prefix) + 1;
|
fname += strlen(me->prefix) + 1;
|
||||||
if (stat("/assets", &bf)) {
|
if (stat("/assets", &bf)) {
|
||||||
|
out->st_mode = me ->vflags ;
|
||||||
out->st_dev = bf.st_dev;
|
out->st_dev = bf.st_dev;
|
||||||
out->st_uid = bf.st_uid;
|
out->st_uid = bf.st_uid;
|
||||||
out->st_gid = bf.st_gid;
|
out->st_gid = bf.st_gid;
|
||||||
@ -165,6 +165,8 @@ static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out) {
|
|||||||
}
|
}
|
||||||
AAsset *a = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
AAsset *a = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
|
if (!a)
|
||||||
|
return false;
|
||||||
out->st_size = AAsset_getLength64(a);
|
out->st_size = AAsset_getLength64(a);
|
||||||
AAsset_close(a);
|
AAsset_close(a);
|
||||||
return true;
|
return true;
|
||||||
@ -173,12 +175,12 @@ static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
bool is_dir_a(VFS_t *me, const char *dirName) {
|
bool is_dir_a(VFS_t *me, const char *dirName) {
|
||||||
dirName += strlen(me->prefix);
|
dirName += strlen(me->prefix)+1;
|
||||||
if (dirName[0] == '\0')
|
if (dirName[0] == '\0')
|
||||||
dirName = "/";
|
return true;
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
AAssetDir *d = AAssetManager_openDir(Yap_assetManager(), dirName);
|
AAssetDir *d = AAssetManager_openDir(Yap_assetManager(), dirName);
|
||||||
if (d == NULL)
|
if (d == NULL || AAssetDir_getNextFileName(d) == NULL)
|
||||||
return false;
|
return false;
|
||||||
(AAssetDir_close(d));
|
(AAssetDir_close(d));
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "isdir %s <%p>", dirName, d);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "isdir %s <%p>", dirName, d);
|
||||||
@ -222,7 +224,7 @@ Yap_InitAssetManager(void) {
|
|||||||
/* init standard VFS */
|
/* init standard VFS */
|
||||||
me = (VFS_t *) Yap_AllocCodeSpace(sizeof(struct vfs));
|
me = (VFS_t *) Yap_AllocCodeSpace(sizeof(struct vfs));
|
||||||
me->name = "/assets";
|
me->name = "/assets";
|
||||||
me->vflags = VFS_CAN_EXEC | VFS_CAN_SEEK |
|
me->vflags = VFS_CAN_EXEC | VFS_CAN_SEEK | VFS_CAN_READ |
|
||||||
VFS_HAS_PREFIX; /// the main flags describing the operation of the Fs.
|
VFS_HAS_PREFIX; /// the main flags describing the operation of the Fs.
|
||||||
me->prefix = "/assets";
|
me->prefix = "/assets";
|
||||||
/** operations */
|
/** operations */
|
||||||
|
34
os/files.c
34
os/files.c
@ -406,6 +406,33 @@ static Int access_file(USES_REGS1) {
|
|||||||
if (!(ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
if (!(ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
VFS_t *vfs;
|
||||||
|
if ((vfs = vfs_owner(ares))) {
|
||||||
|
bool rc = true;
|
||||||
|
vfs_stat o;
|
||||||
|
if (vfs->stat(vfs, ares, &o)) {
|
||||||
|
if (atmode == AtomExist)
|
||||||
|
return true;
|
||||||
|
else if (atmode == AtomExists)
|
||||||
|
return true;
|
||||||
|
else if (atmode == AtomWrite)
|
||||||
|
return o.st_mode & VFS_CAN_WRITE;
|
||||||
|
else if (atmode == AtomRead)
|
||||||
|
return o.st_mode & VFS_CAN_READ;
|
||||||
|
else if (atmode == AtomAppend)
|
||||||
|
return o.st_mode & VFS_CAN_WRITE;
|
||||||
|
else if (atmode == AtomCsult)
|
||||||
|
return o.st_mode & VFS_CAN_READ;
|
||||||
|
else if (atmode == AtomExecute)
|
||||||
|
return o.st_mode & VFS_CAN_EXEC;
|
||||||
|
else {
|
||||||
|
Yap_Error(DOMAIN_ERROR_IO_MODE, tmode, "access_file/2");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rc = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
#if HAVE_ACCESS
|
#if HAVE_ACCESS
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
{
|
{
|
||||||
@ -496,12 +523,7 @@ static Int exists_directory(USES_REGS1) {
|
|||||||
if ((vfs = vfs_owner(s))) {
|
if ((vfs = vfs_owner(s))) {
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
void *o;
|
void *o;
|
||||||
if ((o=vfs->opendir(vfs, s))) {
|
return vfs->isdir(vfs, s);
|
||||||
rc = true;
|
|
||||||
vfs->closedir(o);
|
|
||||||
} else {
|
|
||||||
rc = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -37,10 +37,11 @@ set_property(GLOBAL
|
|||||||
include_directories(. sqlite3)
|
include_directories(. sqlite3)
|
||||||
add_subdirectory(sqlite3)
|
add_subdirectory(sqlite3)
|
||||||
|
|
||||||
MY_add_subdirectory(mysql)
|
if (NOT ANDROID)
|
||||||
MY_add_subdirectory(odbc)
|
add_subdirectory(mysql)
|
||||||
MY_add_subdirectory(postgres)
|
add_subdirectory(odbc)
|
||||||
|
add_subdirectory(postgres)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_component(myddas
|
add_component(myddas
|
||||||
${MYDDAS_SOURCES}
|
${MYDDAS_SOURCES}
|
||||||
|
@ -42,7 +42,7 @@ and_open(struct vfs *me, int sno, const char *name, const char *io_mode) {
|
|||||||
GLOBAL_Stream[sno].vfs = me;
|
GLOBAL_Stream[sno].vfs = me;
|
||||||
GLOBAL_Stream[sno].status = Append_Stream_f | Output_Stream_f;
|
GLOBAL_Stream[sno].status = Append_Stream_f | Output_Stream_f;
|
||||||
GLOBAL_Stream[sno].name = Yap_LookupAtom(name);
|
GLOBAL_Stream[sno].name = Yap_LookupAtom(name);
|
||||||
buff0.clear();
|
buff0.clear(); // does not work?
|
||||||
return streamerInstance;
|
return streamerInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,12 +248,13 @@ initialize_prolog :-
|
|||||||
:- set_prolog_flag(verbose, silent).
|
:- set_prolog_flag(verbose, silent).
|
||||||
%:- set_prolog_flag(verbose_file_search, true ).
|
%:- set_prolog_flag(verbose_file_search, true ).
|
||||||
%:- yap_flag(write_strings,on).
|
%:- yap_flag(write_strings,on).
|
||||||
%:- start_low_level_trace.
|
|
||||||
:- c_compile( 'preds.yap' ).
|
:- c_compile( 'preds.yap' ).
|
||||||
:- c_compile( 'modules.yap' ).
|
:- c_compile( 'modules.yap' ).
|
||||||
:- c_compile( 'grammar.yap' ).
|
:- c_compile( 'grammar.yap' ).
|
||||||
:- ['absf.yap'].
|
:- ['absf.yap'].
|
||||||
|
|
||||||
|
%:- start_low_level_trace.
|
||||||
|
|
||||||
:- use_module('error.yap').
|
:- use_module('error.yap').
|
||||||
|
|
||||||
:- [
|
:- [
|
||||||
|
Reference in New Issue
Block a user