From 5547c13b42f370793ca0e2ed75eed5fb4d2063f0 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sun, 17 Jun 2007 16:38:00 +0000 Subject: On linux, guess the mount point for ipods (tested) and sansas (untested). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13653 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilCtrls.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'rbutil/rbutilCtrls.cpp') diff --git a/rbutil/rbutilCtrls.cpp b/rbutil/rbutilCtrls.cpp index 6164c7dcdd..85545159b5 100644 --- a/rbutil/rbutilCtrls.cpp +++ b/rbutil/rbutilCtrls.cpp @@ -435,6 +435,29 @@ void DeviceSelectorCtrl::OnAutoDetect(wxCommandEvent& event) AutoDetect(); } +#if !(defined( __WXMSW__ ) || defined( __DARWIN__)) +wxString resolve_mount_point( const wxString device ) +{ + FILE *fp = fopen( "/proc/mounts", "r" ); + if( !fp ) return wxT(""); + char *dev, *dir; + while( fscanf( fp, "%as %as %*s %*s %*s %*s", &dev, &dir ) != EOF ) + { + if( wxString( dev, wxConvUTF8 ) == device ) + { + wxString directory = wxString( dir, wxConvUTF8 ); + free( dev ); + free( dir ); + return directory; + } + free( dev ); + free( dir ); + } + fclose( fp ); + return wxT(""); +} +#endif + void DeviceSelectorCtrl::AutoDetect() { struct ipod_t ipod; @@ -445,6 +468,12 @@ void DeviceSelectorCtrl::AutoDetect() int index = gv->plat_bootloadername.Index(temp); // use the bootloader names.. m_deviceCbx->SetValue(gv->plat_name[index]); gv->curplat=gv->plat_id[index]; + +#if !(defined( __WXMSW__ ) || defined( __DARWIN__)) + wxString tmp = resolve_mount_point(wxString(ipod.diskname,wxConvUTF8)+wxT("2")); + if( tmp != wxT("") ) + gv->curdestdir = tmp; +#endif return; } else if (n > 1) @@ -461,6 +490,12 @@ void DeviceSelectorCtrl::AutoDetect() int index = gv->plat_id.Index(wxT("sansae200")); m_deviceCbx->SetValue(gv->plat_name[index]); gv->curplat=gv->plat_id[index]; + +#if !(defined( __WXMSW__ ) || defined( __DARWIN__)) + wxString tmp = resolve_mount_point(wxString(ipod.diskname,wxConvUTF8)+wxT("1")); + if( tmp != wxT("") ) + gv->curdestdir = tmp; +#endif return; } else if (n2 > 1) @@ -544,7 +579,8 @@ void DevicePositionCtrl::setDefault() void DevicePositionCtrl::OnBrowseBtn(wxCommandEvent& event) { const wxString& temp = wxDirSelector( - wxT("Please select the location of your audio device"), gv->curdestdir); + wxT("Please select the location of your audio device"), gv->curdestdir, + 0, wxDefaultPosition, this); if (!temp.empty()) { -- cgit v1.2.3