MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / OnFileOpened

Function OnFileOpened

Applications/FileManager/main.cpp:12–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <unistd.h>
11
12void OnFileOpened(const char* path, Lemon::GUI::FileView* fv){
13 char* pathCopy = strdup(path);
14
15 if(strncmp(path + strlen(path) - 4, ".lef", 4) == 0){
16 lemon_spawn(path, 1, &pathCopy);
17 } else if(strncmp(path + strlen(path) - 4, ".txt", 4) == 0 || strncmp(path + strlen(path) - 4, ".cfg", 4) == 0 || strncmp(path + strlen(path) - 4, ".asm", 4) == 0 || strncmp(path + strlen(path) - 3, ".py", 3) == 0 || strncmp(path + strlen(path) - 5, ".json", 5) == 0){
18 char* const argv[] = {const_cast<char*>("/system/bin/textedit.lef"), pathCopy};
19 lemon_spawn("/system/bin/textedit.lef", 2, argv);
20 } else if(strncmp(path + strlen(path) - 4, ".png", 4) == 0 || strncmp(path + strlen(path) - 4, ".bmp", 4) == 0){
21 char* const argv[] = {const_cast<char*>("/system/bin/imgview.lef"), pathCopy};
22 lemon_spawn("/system/bin/imgview.lef", 2, argv);
23 }
24
25 free(pathCopy);
26}
27
28extern "C"
29int main(int argc, char** argv){

Callers 1

OnSubmitMethod · 0.85

Calls 4

strdupFunction · 0.85
strncmpFunction · 0.85
strlenFunction · 0.85
lemon_spawnFunction · 0.85

Tested by

no test coverage detected