MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / fileListAddEntry

Function fileListAddEntry

file.c:744–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}
743
744void fileListAddEntry(FileList *list, FileListEntry *entry, int sort) {
745 if (!list || !entry)
746 return;
747
748 entry->next = NULL;
749 entry->previous = NULL;
750
751 if (list->head == NULL) {
752 list->head = entry;
753 list->tail = entry;
754 } else {
755 if (sort != SORT_NONE) {
756 FileListEntry *p = list->head;
757 FileListEntry *previous = NULL;
758
759 char entry_name[MAX_NAME_LENGTH];
760 strcpy(entry_name, entry->name);
761 removeEndSlash(entry_name);
762
763 while (p) {
764 char p_name[MAX_NAME_LENGTH];
765 strcpy(p_name, p->name);
766 removeEndSlash(p_name);
767
768 // '..' is always at first
769 if (strcmp(entry_name, "..") == 0)
770 break;
771
772 if (strcmp(p_name, "..") == 0) {
773 previous = p;
774 p = p->next;
775 continue;
776 }
777
778 // Sort by type
779 if (sort == SORT_BY_NAME) {
780 // First folders then files
781 if (entry->is_folder > p->is_folder)
782 break;
783 } else if (sort == SORT_BY_SIZE || sort == SORT_BY_DATE) {
784 // First files then folders
785 if (entry->is_folder < p->is_folder)
786 break;
787 }
788
789 if (sort == SORT_BY_NAME) {
790 // Sort by name within the same type
791 if (entry->is_folder == p->is_folder) {
792 if (strnatcasecmp(entry_name, p_name) < 0) {
793 break;
794 }
795 }
796 } else if (sort == SORT_BY_SIZE) {
797 // Sort by name for folders
798 if (entry->is_folder && p->is_folder) {
799 if (strnatcasecmp(entry_name, p_name) < 0) {
800 break;
801 }

Callers 8

fileListGetPsarcEntriesFunction · 0.85
fileListGetDeviceEntriesFunction · 0.85
fileBrowserMenuCtrlFunction · 0.85
dialogStepsFunction · 0.85

Calls 2

removeEndSlashFunction · 0.85
strnatcasecmpFunction · 0.85

Tested by

no test coverage detected