| 2003 | if (panels && cJSON_IsArray(panels)) { |
| 2004 | cJSON* panel; |
| 2005 | cJSON_ArrayForEach(panel, panels) { |
| 2006 | cJSON* path_item = cJSON_GetObjectItem(panel, "Path"); |
| 2007 | if (path_item && cJSON_IsString(path_item)) { |
| 2008 | char panel_path[MAX_PATH * 4]; |
| 2009 | strncpy(panel_path, path_item->valuestring, sizeof(panel_path) - 1); |
| 2010 | panel_path[sizeof(panel_path) - 1] = 0; |
| 2011 | for (char* p = panel_path; *p; p++) { |
| 2012 | if (*p == '\\') *p = '/'; |
| 2013 | if (*p >= 'A' && *p <= 'Z') *p = *p + ('a' - 'A'); |
| 2014 | } |
| 2015 | size_t plen = strlen(panel_path); |
| 2016 | if (plen > 0 && panel_path[plen-1] == '/') panel_path[plen-1] = 0; |
| 2017 | |
| 2018 | if (strcmp(folder_utf8, panel_path) == 0) { |
| 2019 | cJSON* sorted_by = cJSON_GetObjectItem(panel, "SortedBy"); |
| 2020 | if (sorted_by && cJSON_IsNumber(sorted_by)) { |
| 2021 | int sort_val = sorted_by->valueint; |
| 2022 | DLOG_SORT("Found folder in FilePilot! SortedBy=%d", sort_val); |
| 2023 | |
| 2024 | // FilePilot SortBy: 0=None, 1/3=NameAsc, 2/4=NameDesc, 5=SizeAsc, 6=SizeDesc, |
| 2025 | // 7/9=DateAsc, 8/10=DateDesc, 17=TypeAsc, 18=TypeDesc |
| 2026 | switch (sort_val) { |
| 2027 | case 1: case 3: *detected_sort = Sort_Order_Name_Asc; found = true; break; |
| 2028 | case 2: case 4: *detected_sort = Sort_Order_Name_Desc; found = true; break; |
| 2029 | case 5: *detected_sort = Sort_Order_Size_Asc; found = true; break; |
| 2030 | case 6: *detected_sort = Sort_Order_Size_Desc; found = true; break; |
| 2031 | case 7: case 9: *detected_sort = Sort_Order_Date_Asc; found = true; break; |
| 2032 | case 8: case 10: *detected_sort = Sort_Order_Date_Desc; found = true; break; |
| 2033 | case 17: *detected_sort = Sort_Order_Type_Asc; found = true; break; |
| 2034 | case 18: *detected_sort = Sort_Order_Type_Desc; found = true; break; |
| 2035 | } |
| 2036 | break; |
| 2037 | } |
| 2038 | } |
| 2039 | } |
| 2040 | } |
| 2041 | } |
| 2042 | } |
| 2043 |
no test coverage detected