kjb_fopen - A front end for fopen


#include "l/l_sys_io.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

FILE *kjb_fopen
	const char *input_fd_name,
	const char *mode


The routine kjb_fopen should be used to open files that are used with the KJB library. It implements additional features such as more comprehensive diagnostics, and sytem independent determination of file name from the file pointer. It also implements acceptance of the "b" (for binary) mode character. (This is STILL not universally available). Another feature is a routine print_open_files (development version only!) to print all open files. An additional feature is that "~", and "~users"" is expanded. Of course, this means that you cannot open a file that starts with a double ~. If the user settable option "disable-dir-open" is set, then an open attempt on a directory failes. If the user settable option "uncompress-files" is set, and the filenanme has suffix ".gz" or ".Z", then the file is uncompressed into tempory space, and the temporary file is opened instead. The temporary file is removed on file close. Files opened with kjb_fopen MUST be closed with kjb_fclose. This function is not re-entrant (i.e., not thread-safe).


A regular FILE* handle on success, and NULL on failure.


Many KJB library routines requiring a file pointer will assume that this pointer came from one of kjb_fopen, kjb_freopen, kjb_popen, or kjb_fdopen. Furthermore the library assumes that all files opened with one of these routines will be closed with kjb_fclose. Furthermore, the KJB library file IO routines assume that stdin, stdout, and stderr will not be closed with fclose (kjb_fclose is OK). In short, if one makes use of the IO portion of the library, then kjb_fopen and friends should be used. Using file pointers obtained from kjb_fopen with non KJB library routines is less critical, but can lead to minor problems such as incorrect paging. Of course, when there is no non-KJB library routine for the given task, then there is no problem.


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


set_low_level_io_options , kjb_read_exact , kjb_read , kjb_read_2 , safe_pipe_write , kjb_write , kjb_write_2 , kjb_fread_exact , kjb_fread , kjb_fread_2 , kjb_fwrite , kjb_fwrite_2 , kjb_safe_fflush , kjb_fflush , kjb_ioctl , set_blocking , set_no_blocking , stdin_get_line , fget_line , dget_line , fput_line , kjb_mkdir , kjb_mkdir_2 , kjb_unlink , kjb_unlink_2 , kjb_rmdir , kjb_freopen , kjb_fdopen , kjb_fclose , kjb_realpath , get_fd_name , get_user_fd_name , kjb_fseek , kjb_ftell , kjb_fputs , kjb_fgetc , kjb_fputc , pso , p_stderr , kjb_fprintf , pdo , kjb_vfprintf , is_file , is_directory , fp_get_path_type , get_path_type , get_file_size , fp_get_byte_size , get_file_age , stream_younger , stream_older , get_file_mod_time , kjb_isatty , print_underlined , start_stdout_shadow , stop_stdout_shadow , start_stderr_shadow , stop_stderr_shadow , enable_stdout , disable_stdout , kjb_glob , kjb_simple_glob