This commit is contained in:
parent
2349ac8488
commit
fc7de5a9da
1 changed files with 15 additions and 13 deletions
28
debugger.cpp
28
debugger.cpp
|
@ -172,30 +172,32 @@ std::optional<std::string> select_host_file(console *const cnsl)
|
||||||
for(;;) {
|
for(;;) {
|
||||||
cnsl->flush_input();
|
cnsl->flush_input();
|
||||||
|
|
||||||
std::string selected_file = cnsl->read_line("Enter filename (or empty to abort): ");
|
std::string selected_file = cnsl->read_line("Enter filename (\"dir\" for listing or empty to abort): ");
|
||||||
|
|
||||||
if (selected_file.empty())
|
if (selected_file.empty())
|
||||||
return { };
|
return { };
|
||||||
|
|
||||||
cnsl->put_string("Opening file: ");
|
if (selected_file != "dir") {
|
||||||
cnsl->put_string_lf(selected_file.c_str());
|
cnsl->put_string("Opening file: ");
|
||||||
|
cnsl->put_string_lf(selected_file.c_str());
|
||||||
|
|
||||||
bool can_open_file = false;
|
bool can_open_file = false;
|
||||||
|
|
||||||
#if IS_POSIX || defined(_WIN32)
|
#if IS_POSIX || defined(_WIN32)
|
||||||
struct stat st { };
|
struct stat st { };
|
||||||
can_open_file = ::stat(selected_file.c_str(), &st) == 0;
|
can_open_file = ::stat(selected_file.c_str(), &st) == 0;
|
||||||
#else
|
#else
|
||||||
File32 fh;
|
File32 fh;
|
||||||
can_open_file = fh.open(selected_file.c_str(), O_RDWR);
|
can_open_file = fh.open(selected_file.c_str(), O_RDWR);
|
||||||
if (can_open_file)
|
if (can_open_file)
|
||||||
fh.close();
|
fh.close();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (can_open_file)
|
if (can_open_file)
|
||||||
return selected_file;
|
return selected_file;
|
||||||
|
|
||||||
cnsl->put_string_lf("open failed");
|
cnsl->put_string_lf("open failed");
|
||||||
|
}
|
||||||
|
|
||||||
ls_l(cnsl);
|
ls_l(cnsl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue