2004-11-17 06:00:25 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "../include/FileSystem.h"
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
FileSystem::FileSystem()
|
2004-11-21 14:49:38 -07:00
|
|
|
{
|
|
|
|
cylinder_size = 0 ;
|
|
|
|
}
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
int FileSystem::execute_command( std::vector<std::string> argv, std::vector<OperationDetails> & operation_details )
|
|
|
|
{
|
|
|
|
Glib::ustring temp ;
|
|
|
|
for ( unsigned int t = 0 ; t < argv .size() ; t++ )
|
|
|
|
temp += argv[ t ] + " " ;
|
|
|
|
|
2006-01-28 08:09:50 -07:00
|
|
|
operation_details .push_back( OperationDetails( "<b><i>" + temp + "</i></b>", OperationDetails::NONE ) ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Glib::spawn_sync( ".",
|
|
|
|
argv,
|
|
|
|
Glib::SPAWN_SEARCH_PATH,
|
|
|
|
sigc::slot< void >(),
|
|
|
|
&output,
|
|
|
|
&error,
|
|
|
|
&exit_status ) ;
|
|
|
|
}
|
|
|
|
catch ( Glib::Exception & e )
|
|
|
|
{
|
2006-01-19 16:30:17 -07:00
|
|
|
if ( ! e .what() .empty() )
|
|
|
|
operation_details .back() .sub_details .push_back( OperationDetails( e .what(), OperationDetails::NONE ) ) ;
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
return -1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! output .empty() )
|
2006-01-28 08:09:50 -07:00
|
|
|
operation_details .back() .sub_details .push_back( OperationDetails( "<i>" + output + "</i>", OperationDetails::NONE ) ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
if ( ! error .empty() )
|
2006-01-28 08:09:50 -07:00
|
|
|
operation_details .back() .sub_details .push_back( OperationDetails( "<i>" + error + "</i>", OperationDetails::NONE ) ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
return exit_status ;
|
2004-11-17 06:00:25 -07:00
|
|
|
}
|
|
|
|
|
2006-01-22 06:23:58 -07:00
|
|
|
int FileSystem::execute_command( std::vector<std::string> argv, std::string & output )
|
|
|
|
{
|
|
|
|
std::vector<std::string> envp ;
|
|
|
|
envp .push_back( "LC_ALL=C" ) ;
|
2006-01-29 12:28:50 -07:00
|
|
|
envp .push_back( "PATH=" + Glib::getenv( "PATH" ) ) ;
|
2006-01-22 06:23:58 -07:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Glib::spawn_sync( ".",
|
|
|
|
argv,
|
|
|
|
envp,
|
|
|
|
Glib::SPAWN_SEARCH_PATH,
|
|
|
|
sigc::slot<void>(),
|
|
|
|
&output,
|
|
|
|
&error, //dummy
|
|
|
|
&exit_status) ;
|
|
|
|
}
|
|
|
|
catch ( Glib::Exception & e )
|
|
|
|
{
|
|
|
|
std::cout << e .what() << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exit_status ;
|
|
|
|
}
|
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
} //GParted
|