MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / file_options_save_aux

Function file_options_save_aux

src/phcfg.c:67–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65#define PHOTOREC_CFG "photorec.cfg"
66
67static 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
122static FILE *file_options_load_aux(void)
123{

Callers 1

file_options_saveFunction · 0.85

Calls 1

MALLOCFunction · 0.85

Tested by

no test coverage detected