Changeset 1133 in MondoRescue for branches/stable/mondo/src/lib/mr_file.c
- Timestamp:
- Feb 11, 2007, 12:02:57 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/lib/mr_file.c
r1100 r1133 19 19 /*open and read file: each call must be coupled with mr_conf_close 20 20 function: return 0 if success*/ 21 FILE *mr_fopen (const char *path, const char *mode) {21 FILE *mr_fopen_int(const char *path, const char *mode,int line, char *file) { 22 22 FILE *fd = NULL; 23 23 24 24 if ((fd = fopen(path, mode)) == NULL) { 25 mr_msg( 0,"Unable to open %s",path);25 mr_msg(1,line,file,"Unable to open %s",path); 26 26 mr_exit(-1,"Exiting"); 27 27 } … … 29 29 } 30 30 31 void mr_fprintf (FILE *fd, const char *fmt, ...) {31 void mr_fprintf_int(FILE *fd, int line, char *file, const char *fmt, ...) { 32 32 33 33 va_list args; 34 34 35 35 if (fd == NULL) { 36 mr_log_exit(-1,"fd is NULL.\nShould NOT happen.\nExiting"); 36 mr_msg(1,line,file,"fd is NULL.\nShould NOT happen."); 37 mr_exit(-1,"Exiting"); 37 38 } 38 39 va_start(args,fmt); 39 40 if (vfprintf(fd, fmt, args) < 0) { 40 mr_msg(0,"Unable to print '%s'",args); 41 mr_msg(1,line,file,"Unable to print to fd"); 42 mr_exit(-1,"Exiting"); 41 43 } 42 44 va_end(args); 43 45 } 44 46 45 void mr_fclose (FILE *fd) {47 void mr_fclose_int(FILE **fd, int line, char *file) { 46 48 47 if (fd == NULL) { 48 mr_log_exit(-1,"fd is NULL.\nShould NOT happen.\nExiting"); 49 if (**fd == NULL) { 50 mr_msg(1,line,file,"fd is NULL.\nShould NOT happen."); 51 mr_exit(-1,"Exiting"); 49 52 } 50 if (fclose(fd) < 0) { 51 mr_msg(0,"Unable to close fd"); 53 if (*fd == NULL) { 54 mr_msg(1,line,file,"File descriptor is NULL.\nShould NOT happen."); 55 mr_exit(-1,"Exiting"); 52 56 } 53 fd = NULL; 57 if (fclose(*fd) < 0) { 58 mr_msg(1,line,file,"Unable to close File Descriptor"); 59 } 60 *fd = NULL; 54 61 } 55 62 56 void mr_mkdir (const char *pathname, mode_t mode) {63 void mr_mkdir_int(const char *pathname, mode_t mode, int line, char *file) { 57 64 58 65 if (mkdir(pathname,mode) != 0) { 59 mr_msg( "Unable to create directory %s",pathname);66 mr_msg(1,line,file,"Unable to create directory %s",pathname); 60 67 mr_exit(-1,"Exiting"); 61 68 }
Note:
See TracChangeset
for help on using the changeset viewer.