| 65 | #define PHOTOREC_CFG "photorec.cfg" |
| 66 | |
| 67 | static FILE *file_options_save_aux(void) |
| 68 | { |
| 69 | char *filename=NULL; |
| 70 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
| 71 | { |
| 72 | char *path; |
| 73 | path = getenv("USERPROFILE"); |
| 74 | if (path == NULL) |
| 75 | path = getenv("HOMEPATH"); |
| 76 | if(path!=NULL) |
| 77 | { |
| 78 | filename=(char*)MALLOC(strlen(path)+strlen(WIN_PHOTOREC_CFG)+1); |
| 79 | strcpy(filename, path); |
| 80 | strcat(filename, WIN_PHOTOREC_CFG); |
| 81 | } |
| 82 | } |
| 83 | #endif |
| 84 | #if !defined(DJGPP) && !defined(DISABLED_FOR_FRAMAC) |
| 85 | if(filename==NULL) |
| 86 | { |
| 87 | char *home; |
| 88 | home = getenv("HOME"); |
| 89 | if (home != NULL) |
| 90 | { |
| 91 | filename=(char*)MALLOC(strlen(home)+strlen(DOT_PHOTOREC_CFG)+1); |
| 92 | strcpy(filename, home); |
| 93 | strcat(filename, DOT_PHOTOREC_CFG); |
| 94 | } |
| 95 | } |
| 96 | if(filename!=NULL) |
| 97 | { |
| 98 | FILE *handle=fopen(filename,"wb"); |
| 99 | if(handle) |
| 100 | { |
| 101 | log_info("Create file %s\n", filename); |
| 102 | free(filename); |
| 103 | return handle; |
| 104 | } |
| 105 | log_error("Can't create file %s: %s\n", filename, strerror(errno)); |
| 106 | free(filename); |
| 107 | filename=NULL; |
| 108 | } |
| 109 | #endif |
| 110 | { |
| 111 | FILE *handle=fopen(PHOTOREC_CFG,"wb"); |
| 112 | if(handle) |
| 113 | { |
| 114 | log_info("Create file %s\n", PHOTOREC_CFG); |
| 115 | return handle; |
| 116 | } |
| 117 | log_error("Can't create file %s: %s\n", PHOTOREC_CFG, strerror(errno)); |
| 118 | } |
| 119 | return NULL; |
| 120 | } |
| 121 | |
| 122 | static FILE *file_options_load_aux(void) |
| 123 | { |
no test coverage detected