MCPcopy Create free account
hub / github.com/TASEmulators/fceux / UpdateRWRecentArray

Function UpdateRWRecentArray

src/drivers/win/ramwatch.cpp:311–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311void UpdateRWRecentArray(const char* addString, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId)
312{
313 const size_t len = 1024; // Avoid magic numbers
314
315 // Try to find out if the filename is already in the recent files list.
316 for(unsigned int x = 0; x < arrayLen; x++)
317 {
318 if(strlen(rw_recent_files[x]))
319 {
320 if(!strncmp(rw_recent_files[x], addString, 1024)) // Item is already in list.
321 {
322 // If the filename is in the file list don't add it again.
323 // Move it up in the list instead.
324
325 int y;
326 char tmp[len];
327
328 // Save pointer.
329 strncpy(tmp, rw_recent_files[x], len);
330
331 for(y = x; y; y--)
332 {
333 // Move items down.
334 strncpy(rw_recent_files[y],rw_recent_files[y - 1], len);
335 }
336
337 // Put item on top.
338 strncpy(rw_recent_files[0],tmp, len);
339
340 // Update the recent files menu
341 UpdateRW_RMenu(menu, menuItem, baseId);
342
343 return;
344 }
345 }
346 }
347
348 // The filename wasn't found in the list. That means we need to add it.
349
350 // Move the other items down.
351 for(unsigned int x = arrayLen - 1; x; x--)
352 {
353 strncpy(rw_recent_files[x],rw_recent_files[x - 1], len);
354 }
355
356 // Add the new item.
357 strncpy(rw_recent_files[0], addString, len);
358
359 // Update the recent files menu
360 UpdateRW_RMenu(menu, menuItem, baseId);
361}
362
363void RWAddRecentFile(const char *filename)
364{

Callers 1

RWAddRecentFileFunction · 0.85

Calls 1

UpdateRW_RMenuFunction · 0.85

Tested by

no test coverage detected