summaryrefslogtreecommitdiff
path: root/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'core.c')
-rw-r--r--core.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/core.c b/core.c
index 7d2600b..91038fc 100644
--- a/core.c
+++ b/core.c
@@ -112,6 +112,19 @@ int file_open_fn( file_t *ft, const char *filename, int flags )
int ret = 0;
int fd;
+ //check if file is allready initialized or opened
+ if (ft->fd > 0)
+ {
+ printf("Trying to open file but file descriptor allready set\n");
+ return -1;
+ }
+
+ if (ft->filename != NULL)
+ {
+ printf("Trying open file, bus structure allready have filename\n");
+ return -1;
+ }
+
fd = fd_open( filename, flags );
if ( fd < 1 )
{
@@ -378,10 +391,14 @@ int file_close( file_t *ft )
{
printf("File name is empty\n");
return -1;
+ } else {
+ free(ft->filename);
+ ft->filename = NULL;
}
fd_close( ft->fd );
memset( ft, 0, sizeof(file_t) );
+ ft->fd = -1;
return ret;
}