mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
BACKENDS: Make browser_lastpath a Path object
This commit is contained in:
parent
c34e475a0e
commit
db41390587
@ -55,7 +55,7 @@ Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const
|
||||
struct FileRequester *fr = nullptr;
|
||||
|
||||
if (ConfMan.hasKey("browser_lastpath")) {
|
||||
strncpy(pathBuffer, ConfMan.get("browser_lastpath").c_str(), sizeof(pathBuffer) - 1);
|
||||
strncpy(pathBuffer, ConfMan.getPath("browser_lastpath").toString(Common::Path::kNativeSeparator).c_str(), sizeof(pathBuffer) - 1);
|
||||
}
|
||||
|
||||
fr = (struct FileRequester *)IAsl->AllocAslRequestTags(ASL_FileRequest, TAG_DONE);
|
||||
@ -70,8 +70,9 @@ Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const
|
||||
if (!isDirBrowser) {
|
||||
IDOS->AddPart(pathBuffer, fr->fr_File, sizeof(pathBuffer));
|
||||
}
|
||||
choice = Common::FSNode(pathBuffer);
|
||||
ConfMan.set("browser_lastpath", pathBuffer);
|
||||
Common::Path path(pathBuffer);
|
||||
choice = Common::FSNode(path);
|
||||
ConfMan.setPath("browser_lastpath", path);
|
||||
result = kDialogOk;
|
||||
}
|
||||
IAsl->FreeAslRequest((APTR)fr);
|
||||
|
@ -83,7 +83,7 @@ Common::DialogManager::DialogResult GtkDialogManager::showFileBrowser(const Comm
|
||||
// Customize dialog
|
||||
gtk_file_chooser_set_show_hidden(chooser, ConfMan.getBool("gui_browser_show_hidden", Common::ConfigManager::kApplicationDomain));
|
||||
if (ConfMan.hasKey("browser_lastpath")) {
|
||||
gtk_file_chooser_set_current_folder(chooser, ConfMan.get("browser_lastpath").c_str());
|
||||
gtk_file_chooser_set_current_folder(chooser, ConfMan.getPath("browser_lastpath").toString(Common::Path::kNativeSeparator).c_str());
|
||||
}
|
||||
|
||||
// Show dialog
|
||||
@ -99,11 +99,12 @@ Common::DialogManager::DialogResult GtkDialogManager::showFileBrowser(const Comm
|
||||
#endif
|
||||
if (res == GTK_RESPONSE_ACCEPT) {
|
||||
// Get the selection from the user
|
||||
char *path = gtk_file_chooser_get_filename(chooser);
|
||||
char *pathS = gtk_file_chooser_get_filename(chooser);
|
||||
Common::Path path(pathS, Common::Path::kNativeSeparator);
|
||||
choice = Common::FSNode(path);
|
||||
ConfMan.set("browser_lastpath", path);
|
||||
ConfMan.setPath("browser_lastpath", path);
|
||||
result = kDialogOk;
|
||||
g_free(path);
|
||||
g_free(pathS);
|
||||
}
|
||||
|
||||
_inDialog = FALSE;
|
||||
|
@ -46,7 +46,7 @@ Common::DialogManager::DialogResult MorphosDialogManager::showFileBrowser(const
|
||||
struct FileRequester *fr = NULL;
|
||||
|
||||
if (ConfMan.hasKey("browser_lastpath")) {
|
||||
strncpy(pathBuffer, ConfMan.get("browser_lastpath").c_str(), sizeof(pathBuffer) - 1);
|
||||
strncpy(pathBuffer, ConfMan.getPath("browser_lastpath").toString(Common::Path::kNativeSeparator).c_str(), sizeof(pathBuffer) - 1);
|
||||
}
|
||||
|
||||
fr = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, TAG_DONE);
|
||||
@ -58,7 +58,7 @@ Common::DialogManager::DialogResult MorphosDialogManager::showFileBrowser(const
|
||||
|
||||
if (strlen(fr->fr_Drawer) < sizeof(pathBuffer)) {
|
||||
strncpy(pathBuffer, fr->fr_Drawer, sizeof(pathBuffer));
|
||||
ConfMan.set("browser_lastpath", pathBuffer); // only path
|
||||
ConfMan.setPath("browser_lastpath", pathBuffer); // only path
|
||||
if (!isDirBrowser) {
|
||||
AddPart(pathBuffer, fr->fr_File, sizeof(pathBuffer));
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ HRESULT winCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid,
|
||||
return func(pszPath, pbc, riid, ppv);
|
||||
}
|
||||
|
||||
HRESULT getShellPath(IShellItem *item, Common::String &path) {
|
||||
HRESULT getShellPath(IShellItem *item, Common::Path &path) {
|
||||
LPWSTR name = nullptr;
|
||||
HRESULT hr = item->GetDisplayName(SIGDN_FILESYSPATH, &name);
|
||||
if (SUCCEEDED(hr)) {
|
||||
char *str = Win32::unicodeToAnsi(name);
|
||||
path = Common::String(str);
|
||||
path = Common::Path(str, Common::Path::kNativeSeparator);
|
||||
CoTaskMemFree(name);
|
||||
free(str);
|
||||
}
|
||||
@ -139,7 +139,7 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const Co
|
||||
|
||||
LPWSTR str;
|
||||
if (ConfMan.hasKey("browser_lastpath")) {
|
||||
str = Win32::ansiToUnicode(ConfMan.get("browser_lastpath").c_str());
|
||||
str = Win32::ansiToUnicode(ConfMan.getPath("browser_lastpath").toString(Common::Path::kNativeSeparator).c_str());
|
||||
IShellItem *item = nullptr;
|
||||
hr = winCreateItemFromParsingName(str, nullptr, IID_IShellItem, reinterpret_cast<void **> (&(item)));
|
||||
if (SUCCEEDED(hr)) {
|
||||
@ -156,7 +156,7 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const Co
|
||||
IShellItem *selectedItem = nullptr;
|
||||
hr = dialog->GetResult(&selectedItem);
|
||||
if (SUCCEEDED(hr)) {
|
||||
Common::String path;
|
||||
Common::Path path;
|
||||
hr = getShellPath(selectedItem, path);
|
||||
if (SUCCEEDED(hr)) {
|
||||
choice = Common::FSNode(path);
|
||||
@ -169,10 +169,10 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const Co
|
||||
IShellItem *lastFolder = nullptr;
|
||||
hr = dialog->GetFolder(&lastFolder);
|
||||
if (SUCCEEDED(hr)) {
|
||||
Common::String path;
|
||||
Common::Path path;
|
||||
hr = getShellPath(lastFolder, path);
|
||||
if (SUCCEEDED(hr)) {
|
||||
ConfMan.set("browser_lastpath", path);
|
||||
ConfMan.setPath("browser_lastpath", path);
|
||||
}
|
||||
lastFolder->Release();
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ void OSystem_Android::initBackend() {
|
||||
}
|
||||
|
||||
if (!ConfMan.hasKey("browser_lastpath")) {
|
||||
ConfMan.set("browser_lastpath", "/");
|
||||
ConfMan.setPath("browser_lastpath", "/");
|
||||
}
|
||||
|
||||
if (!ConfMan.hasKey("gui_scale")) {
|
||||
|
@ -186,12 +186,12 @@ void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
||||
|
||||
void BrowserDialog::updateListing() {
|
||||
// Update the path display
|
||||
_currentPath->setEditString(_node.getPath());
|
||||
_currentPath->setEditString(_node.getPath().toString(Common::Path::kNativeSeparator));
|
||||
|
||||
// We memorize the last visited path.
|
||||
// Don't memorize a path that is not a directory
|
||||
if (_node.isDirectory()) {
|
||||
ConfMan.set("browser_lastpath", _node.getPath());
|
||||
ConfMan.setPath("browser_lastpath", _node.getPath());
|
||||
}
|
||||
|
||||
// Read in the data from the file system
|
||||
|
Loading…
x
Reference in New Issue
Block a user