diff options
Diffstat (limited to 'core.c')
-rw-r--r-- | core.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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; } |