summaryrefslogtreecommitdiff
path: root/src/persistence_client_library_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/persistence_client_library_file.c')
-rw-r--r--src/persistence_client_library_file.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index a98357b..6c1e3fe 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -103,7 +103,8 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
// get database context: database path and database key
shared_DB = get_db_context(&dbContext, resource_id, ResIsFile, dbKey, dbPath);
- if(shared_DB != -1) // check valid database context
+ if( (shared_DB >= 0) // check valid database context
+ && (dbContext.configKey.type == PersistenceResourceType_file) ) // check if type matches
{
handle = open(dbPath, flags);
if(handle != -1)
@@ -178,10 +179,15 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
}
else
{
- printf("file_open ==> no valid path to create: %s\n", dbPath);
+ printf("pclFileOpen ==> no valid path to create: %s\n", dbPath);
}
}
}
+ else
+ {
+ handle = shared_DB;
+ printf("pclFileOpen ==> no valid database context or resource no file\n");
+ }
return handle;
}
@@ -217,7 +223,8 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user
// get database context: database path and database key
shared_DB = get_db_context(&dbContext, resource_id, ResIsFile, dbKey, dbPath);
- if(shared_DB != -1) // check valid database context
+ if( (shared_DB >= 0) // check valid database context
+ && (dbContext.configKey.type == PersistenceResourceType_file) ) // check if type matches
{
rval = remove(dbPath);
if(rval == -1)
@@ -225,6 +232,11 @@ int pclFileRemove(unsigned int ldbid, const char* resource_id, unsigned int user
printf("file_remove ERROR: %s \n", strerror(errno) );
}
}
+ else
+ {
+ rval = shared_DB;
+ printf("pclFileRemove ==> no valid database context or resource not a file\n");
+ }
}
else
{