mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
Fixed directory browsing to work properly in Windows.
This commit is contained in:
parent
f6115375ab
commit
469a2596c7
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
||||
**/CMakeFiles
|
||||
**/Makefile
|
||||
**/cmake_install.cmake
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
ipch
|
||||
|
@ -92,9 +92,9 @@ std::string musik::core::GetHomeDirectory() {
|
||||
std::string directory;
|
||||
|
||||
#ifdef WIN32
|
||||
DWORD bufferSize = GetEnvironmentVariable(_T("HOMEPATH"), 0, 0);
|
||||
DWORD bufferSize = GetEnvironmentVariable(_T("USERPROFILE"), 0, 0);
|
||||
wchar_t *buffer = new wchar_t[bufferSize + 2];
|
||||
GetEnvironmentVariable(_T("HOMEPATH"), buffer, bufferSize);
|
||||
GetEnvironmentVariable(_T("USERPROFILE"), buffer, bufferSize);
|
||||
directory.assign(u16to8(buffer));
|
||||
delete[] buffer;
|
||||
#else
|
||||
|
@ -45,6 +45,21 @@ using namespace musik::box;
|
||||
using namespace cursespp;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
#ifdef WIN32
|
||||
void buildDriveList(std::vector<std::string>& target) {
|
||||
target.clear();
|
||||
static char buffer[4096];
|
||||
DWORD result = ::GetLogicalDriveStringsA(4096, buffer);
|
||||
if (result) {
|
||||
char* current = buffer;
|
||||
while (*current) {
|
||||
target.push_back(std::string(current));
|
||||
current += strlen(current) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void buildDirectoryList(const path& p, std::vector<std::string>& target)
|
||||
{
|
||||
target.clear();
|
||||
@ -64,7 +79,7 @@ void buildDirectoryList(const path& p, std::vector<std::string>& target)
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
/* todo: log */
|
||||
/* todo: log maybe? */
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +101,17 @@ void DirectoryAdapter::Select(size_t index) {
|
||||
dir /= this->subdirs[hasParent ? index - 1 : index];
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
std::string pathstr = this->dir.string();
|
||||
if ((pathstr.size() == 2 && pathstr[1] == ':') ||
|
||||
(pathstr.size() == 3 && pathstr[2] == ':'))
|
||||
{
|
||||
dir = path();
|
||||
buildDriveList(subdirs);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
buildDirectoryList(dir, subdirs);
|
||||
}
|
||||
|
||||
@ -112,5 +138,6 @@ IScrollAdapter::EntryPtr DirectoryAdapter::GetEntry(size_t index) {
|
||||
}
|
||||
--index;
|
||||
}
|
||||
|
||||
return IScrollAdapter::EntryPtr(new SingleLineEntry(this->subdirs[index]));
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ static EmptyAdapter emptyAdapter;
|
||||
|
||||
ListWindow::ListWindow(IScrollAdapter* adapter, IWindow *parent)
|
||||
: ScrollableWindow(parent)
|
||||
, adapter(adapter) {
|
||||
, adapter(adapter)
|
||||
, selectedIndex(0) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,7 @@
|
||||
<ClCompile Include="app\layout\NowPlayingLayout.cpp" />
|
||||
<ClCompile Include="app\layout\SearchLayout.cpp" />
|
||||
<ClCompile Include="app\layout\TrackSearchLayout.cpp" />
|
||||
<ClCompile Include="app\model\DirectoryAdapter.cpp" />
|
||||
<ClCompile Include="app\model\TrackList.cpp" />
|
||||
<ClCompile Include="app\query\CategoryListViewQuery.cpp" />
|
||||
<ClCompile Include="app\query\NowPlayingTrackListQuery.cpp" />
|
||||
@ -170,6 +171,7 @@
|
||||
<ClInclude Include="app\layout\NowPlayingLayout.h" />
|
||||
<ClInclude Include="app\layout\SearchLayout.h" />
|
||||
<ClInclude Include="app\layout\TrackSearchLayout.h" />
|
||||
<ClInclude Include="app\model\DirectoryAdapter.h" />
|
||||
<ClInclude Include="app\model\TrackList.h" />
|
||||
<ClInclude Include="app\query\CategoryListViewQuery.h" />
|
||||
<ClInclude Include="app\query\NowPlayingTrackListQuery.h" />
|
||||
|
@ -126,6 +126,9 @@
|
||||
<ClCompile Include="app\layout\IndexerLayout.cpp">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\model\DirectoryAdapter.cpp">
|
||||
<Filter>app\model</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
@ -294,6 +297,9 @@
|
||||
<ClInclude Include="app\layout\IndexerLayout.h">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app\model\DirectoryAdapter.h">
|
||||
<Filter>app\model</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="cursespp">
|
||||
|
Loading…
Reference in New Issue
Block a user