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

Function FileDialogOnFileBoxSubmit

LibLemon/src/gui/filedialog.cpp:33–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32
33 void FileDialogOnFileBoxSubmit(Lemon::GUI::TextBox* box){
34 if(box->contents.front().find('/') != std::string::npos && box->contents.size() > NAME_MAX){
35 DisplayMessageBox("Open...", "Filename is invalid!", MsgButtonsOK);
36 return;
37 }
38
39 std::string path = dialogFileView->currentPath;
40 path += box->contents.front();
41
42 struct stat sResult;
43 int e = stat(path.c_str(), &sResult);
44 if(e && dflags & FILE_DIALOG_CREATE && errno == ENOENT){
45 FileDialogOnFileOpened(path.c_str(), dialogFileView);
46 return;
47 } else if(e && errno == ENOENT) {
48 char buf[512];
49 sprintf(buf, "File %s not found!", path.c_str());
50 DisplayMessageBox("Open...", buf, MsgButtonsOK);
51 return;
52 } else if(e){
53 perror("GUI: FileDialog: ");
54 char buf[512];
55 sprintf(buf, "Error opening file %s (Error code: %d)", path.c_str(), errno);
56 DisplayMessageBox("Open...", buf, MsgButtonsOK);
57 return;
58 } else if((sResult.st_mode & S_IFMT) == S_IFDIR && !(dflags & FILE_DIALOG_DIRECTORIES)) {
59 dialogFileView->OnSubmit(path);
60 return;
61 } else {
62 FileDialogOnFileOpened(path.c_str(), dialogFileView);
63 }
64 }
65
66 void FileDialogOnOKPress(__attribute__((unused)) Lemon::GUI::Button* btn){
67 FileDialogOnFileBoxSubmit(dialogFileBox);

Callers 1

FileDialogOnOKPressFunction · 0.85

Calls 5

DisplayMessageBoxFunction · 0.85
FileDialogOnFileOpenedFunction · 0.85
sizeMethod · 0.80
OnSubmitMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected