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

Function UpdateRecentMovieArray

src/drivers/win/window.cpp:944–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942}
943
944void UpdateRecentMovieArray(const char* addString, char** bufferArray, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId)
945{
946 // Try to find out if the filename is already in the recent files list.
947 for(unsigned int x = 0; x < arrayLen; x++)
948 {
949 if(bufferArray[x])
950 {
951 if(!strcmp(bufferArray[x], addString)) // Item is already in list.
952 {
953 // If the filename is in the file list don't add it again.
954 // Move it up in the list instead.
955
956 int y;
957 char *tmp;
958
959 // Save pointer.
960 tmp = bufferArray[x];
961
962 for(y = x; y; y--)
963 {
964 // Move items down.
965 bufferArray[y] = bufferArray[y - 1];
966 }
967
968 // Put item on top.
969 bufferArray[0] = tmp;
970
971 // Update the recent files menu
972 UpdateMovieRMenu(menu, bufferArray, menuItem, baseId);
973
974 return;
975 }
976 }
977 }
978
979 // The filename wasn't found in the list. That means we need to add it.
980
981 // If there's no space left in the recent files list, get rid of the last
982 // item in the list.
983 if(bufferArray[arrayLen - 1])
984 {
985 free(bufferArray[arrayLen - 1]);
986 }
987
988 // Move the other items down.
989 for(unsigned int x = arrayLen - 1; x; x--)
990 {
991 bufferArray[x] = bufferArray[x - 1];
992 }
993
994 // Add the new item.
995 bufferArray[0] = (char*)malloc(strlen(addString) + 1); //mbg merge 7/17/06 added cast
996 strcpy(bufferArray[0], addString);
997
998 // Update the recent files menu
999 UpdateMovieRMenu(menu, bufferArray, menuItem, baseId);
1000
1001}

Callers 1

AddRecentMovieFileFunction · 0.85

Calls 1

UpdateMovieRMenuFunction · 0.85

Tested by

no test coverage detected