aboutsummaryrefslogtreecommitdiff
path: root/src/jin/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jin/main.cpp')
-rw-r--r--src/jin/main.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/jin/main.cpp b/src/jin/main.cpp
index 31e837f..f76bda7 100644
--- a/src/jin/main.cpp
+++ b/src/jin/main.cpp
@@ -47,38 +47,36 @@ std::string wstrtostr(const std::wstring &wstr)
}
#endif
-std::string BrowseFolder()
+bool BrowseFolder(string& cwd)
{
#ifdef _WIN32
- string path = EXECUTABLE_DIR;
IFileDialog* pfd = NULL;
DWORD dwFlags;
IShellItem* pItem = NULL;
HRESULT hr = CoInitialize(NULL);
- if (FAILED(hr)) goto End;
+ if (FAILED(hr)) return false;
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pfd));
- if (FAILED(hr)) goto End;
+ if (FAILED(hr)) return false;
pfd->SetTitle(DIALOG_TITLE);
hr = pfd->GetOptions(&dwFlags);
- if (FAILED(hr)) goto End;
+ if (FAILED(hr)) return false;
hr = pfd->SetOptions(dwFlags | FOS_PICKFOLDERS);
- if (FAILED(hr)) goto End;
+ if (FAILED(hr)) return false;
hr = pfd->Show(NULL);
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))
- goto End;
+ return false;
hr = pfd->GetResult(&pItem);
- if (FAILED(hr)) goto End;
+ if (FAILED(hr)) return false;
LPWSTR filePath;
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
- if (FAILED(hr)) goto End;
- path = wstrtostr(filePath);
+ if (FAILED(hr)) return false;
+ cwd = wstrtostr(filePath);
CoTaskMemFree(filePath);
pItem->Release();
pfd->Release();
CoUninitialize();
-End:
- return path;
+ return true;
#endif
}
@@ -90,9 +88,12 @@ int main(int argc, char* args[])
cwd = args[1];
#endif
else
- cwd = BrowseFolder();
+ {
+ if (!BrowseFolder(cwd))
+ return 0;
+ }
if (!cwd.empty())
load(cwd.c_str());
return 0;
-}// todo:main.luaĶȡ \ No newline at end of file
+} \ No newline at end of file