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

Function ask_root_directory

src/fat_adv.c:175–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173#define INTER_DIR 16
174
175static int ask_root_directory(const disk_t *disk_car, const partition_t *partition, const file_info_t*dir_list, const unsigned long int cluster)
176{
177 /* Return value
178 * -1: quit
179 * 1: back
180 * other: new cluster
181 * */
182 int car;
183 int quit=0;
184 int offset=0;
185 int pos_num=0;
186 struct td_list_head *pos=dir_list->list.next;
187 WINDOW *window;
188 window=newwin(LINES, COLS, 0, 0); /* full screen */
189 aff_copy(window);
190 wmove(window,4,0);
191 aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
192 wmove(window,6,0);
193 wprintw(window,"Answer Y(es), N(o), Q(uit) or A(bort interactive mode). N or A if not sure.");
194 curs_set(1);
195 do
196 {
197 int i;
198 struct td_list_head *file_walker = NULL;
199 for(i=0, file_walker=dir_list->list.next;
200 file_walker!=&dir_list->list && i<offset;
201 file_walker=file_walker->next,i++);
202 for(i=offset;
203 file_walker!=&dir_list->list && (i-offset)<INTER_DIR;
204 file_walker=file_walker->next,i++)
205 {
206 const file_info_t *current_file=td_list_entry_const(file_walker, const file_info_t, list);
207 char str[11];
208 char datestr[80];
209 wmove(window,8+i-offset,0);
210 wclrtoeol(window); /* before addstr for BSD compatibility */
211 if(&current_file->list==pos)
212 {
213 wattrset(window, A_REVERSE);
214 waddstr(window, ">");
215 }
216 else
217 waddstr(window, " ");
218 set_datestr((char *)&datestr, sizeof(datestr), current_file->td_mtime);
219 mode_string(current_file->st_mode, str);
220 wprintw(window, "%s %3u %3u ",
221 str, (unsigned int)current_file->st_uid, (unsigned int)current_file->st_gid);
222 wprintw(window, "%9llu", (long long unsigned int)current_file->st_size);
223 /* FIXME: screen overlaps due to long filename */
224 wprintw(window, " %s %s\n", datestr, current_file->name);
225 if(&current_file->list==pos)
226 wattroff(window, A_REVERSE);
227 }
228 /* Clear the last line, useful if overlapping */
229 wmove(window,8+i-offset,0);
230 wclrtoeol(window); /* before addstr for BSD compatibility */
231 /* print the cluster in the loop, so */
232 /* the visible cursor will be at the end */

Callers 1

fat32_find_root_clusterFunction · 0.85

Calls 5

aff_partFunction · 0.85
set_datestrFunction · 0.85
mode_stringFunction · 0.85
td_list_emptyFunction · 0.85
aff_copyFunction · 0.70

Tested by

no test coverage detected