fixed error with mountpoints containing whitespaces. (#329247)
* src/GParted_Core.cc: fixed error with mountpoints containing whitespaces. (#329247)
This commit is contained in:
parent
0be40a4f0b
commit
9b02213d27
|
@ -1,3 +1,8 @@
|
||||||
|
2006-01-30 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* src/GParted_Core.cc: fixed error with mountpoints containing
|
||||||
|
whitespaces. (#329247)
|
||||||
|
|
||||||
2006-01-30 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-01-30 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* configure.in: bump to gparted-0.2
|
* configure.in: bump to gparted-0.2
|
||||||
|
|
|
@ -166,14 +166,23 @@ void GParted_Core::init_maps()
|
||||||
|
|
||||||
//initialize mountpoints..
|
//initialize mountpoints..
|
||||||
char node[255], mountpoint[255] ;
|
char node[255], mountpoint[255] ;
|
||||||
|
unsigned int index ;
|
||||||
std::ifstream proc_mounts( "/proc/mounts" ) ;
|
std::ifstream proc_mounts( "/proc/mounts" ) ;
|
||||||
if ( proc_mounts )
|
if ( proc_mounts )
|
||||||
{
|
{
|
||||||
while ( getline( proc_mounts, line ) )
|
while ( getline( proc_mounts, line ) )
|
||||||
if ( line .length() > 0 &&
|
if ( line .length() > 0 &&
|
||||||
line[ 0 ] == '/' &&
|
line[ 0 ] == '/' &&
|
||||||
sscanf( line .c_str(), "%s %s", node, mountpoint ) == 2 )
|
sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 )
|
||||||
mount_info[ node ] = mountpoint ;
|
{
|
||||||
|
//see if mountpoint contains spaces and deal with it
|
||||||
|
line = mountpoint ;
|
||||||
|
index = line .find( "\\040" ) ;
|
||||||
|
if ( index < line .length() )
|
||||||
|
line .replace( index, 4, " " ) ;
|
||||||
|
|
||||||
|
mount_info[ node ] = line ;
|
||||||
|
}
|
||||||
|
|
||||||
proc_mounts .close() ;
|
proc_mounts .close() ;
|
||||||
}
|
}
|
||||||
|
@ -185,10 +194,10 @@ void GParted_Core::init_maps()
|
||||||
while ( getline( etc_mtab, line ) )
|
while ( getline( etc_mtab, line ) )
|
||||||
if ( line .length() > 0 &&
|
if ( line .length() > 0 &&
|
||||||
line[ 0 ] == '/' &&
|
line[ 0 ] == '/' &&
|
||||||
sscanf( line .c_str(), "%s %s", node, mountpoint ) == 2 &&
|
sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 &&
|
||||||
static_cast<Glib::ustring>( mountpoint ) == "/" )
|
static_cast<Glib::ustring>( mountpoint ) == "/" )
|
||||||
{
|
{
|
||||||
mount_info[ node ] = mountpoint ;
|
mount_info[ node ] = "/" ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue