| 54 | } |
| 55 | |
| 56 | static void launchFile(const char* path, argData_s* args, executableMetadata_s* em) |
| 57 | { |
| 58 | if (em && em->scanned && targetProcess == -1) |
| 59 | { |
| 60 | // this is a really shitty implementation of what we should be doing |
| 61 | // i'm really too lazy to do any better right now, but a good solution will come |
| 62 | // (some day) |
| 63 | processEntry_s out[4]; |
| 64 | int out_len = 0; |
| 65 | getBestProcess_2x(em->sectionSizes, (bool*)em->servicesThatMatter, NUM_SERVICESTHATMATTER, out, 4, &out_len); |
| 66 | |
| 67 | // temp : check if we got all the services we want |
| 68 | if ( |
| 69 | em->servicesThatMatter[0] <= out[0].capabilities[0] |
| 70 | && em->servicesThatMatter[1] <= out[0].capabilities[1] |
| 71 | && em->servicesThatMatter[2] <= out[0].capabilities[2] |
| 72 | && em->servicesThatMatter[3] <= out[0].capabilities[3] |
| 73 | && em->servicesThatMatter[4] <= out[0].capabilities[4]) |
| 74 | targetProcess = out[0].processId; |
| 75 | else |
| 76 | { |
| 77 | // temp : if we didn't get everything we wanted, we search for the candidate that has as many highest-priority services as possible |
| 78 | int i, j; |
| 79 | int best_id = 0; |
| 80 | int best_sum = 0; |
| 81 | for (i=0; i<out_len; i++) |
| 82 | { |
| 83 | int sum = 0; |
| 84 | for(j=0; j<NUM_SERVICESTHATMATTER; j++) |
| 85 | sum += (em->servicesThatMatter[j] == 1) && out[i].capabilities[j]; |
| 86 | |
| 87 | if(sum > best_sum) |
| 88 | { |
| 89 | best_id = i; |
| 90 | best_sum = sum; |
| 91 | } |
| 92 | } |
| 93 | targetProcess = out[best_id].processId; |
| 94 | } |
| 95 | } else if (targetProcess != -1) |
| 96 | targetProcess = -2; |
| 97 | |
| 98 | if (targetProcess == -1) |
| 99 | { |
| 100 | fileHandle = launchOpenFile(path); |
| 101 | if (fileHandle==0) |
| 102 | { |
| 103 | errorScreen(textGetString(StrId_IOError), textGetString(StrId_CouldNotOpenFile), path); |
| 104 | return; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | argBufLen = args->dst - (char*)args->buf; |
| 109 | memcpy(argBuf, args->buf, argBufLen); |
| 110 | __system_retAddr = bootloaderJump; |
| 111 | uiExitLoop(); |
| 112 | } |
| 113 |
nothing calls this directly
no test coverage detected