"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/FileSystem.cc" between
gparted-1.2.0.tar.gz and gparted-1.3.0.tar.gz

About: GParted is a graphical partition editor for creating, reorganizing, and deleting disk partitions (using GNU libparted).

FileSystem.cc  (gparted-1.2.0):FileSystem.cc  (gparted-1.3.0)
skipping to change at line 87 skipping to change at line 87
{ {
if( force || cancel_safe ) if( force || cancel_safe )
kill( -pid, SIGINT ); kill( -pid, SIGINT );
} }
static void setup_child() static void setup_child()
{ {
setpgrp(); setpgrp();
} }
// Execute command and capture stdout and stderr to operation details.
int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail, int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail,
ExecFlags flags ) ExecFlags flags )
{ {
StreamSlot empty_stream_slot; StreamSlot empty_stream_slot;
TimedSlot empty_timed_slot; TimedSlot empty_timed_slot;
return execute_command_internal( command, operationdetail, flags, empty_s tream_slot, empty_timed_slot ); return execute_command_internal(command, NULL, operationdetail, flags, em pty_stream_slot, empty_timed_slot);
} }
// Execute command, pass string to stdin and capture stdout and stderr to operat
ion
// details.
int FileSystem::execute_command(const Glib::ustring& command, const char *input,
OperationDetail& operationdetail,
ExecFlags flags)
{
StreamSlot empty_stream_slot;
TimedSlot empty_timed_slot;
return execute_command_internal(command, input, operationdetail, flags, e
mpty_stream_slot, empty_timed_slot);
}
// Execute command, capture stdout and stderr to operation details and run progr
ess
// tracking callback when either stdout or stderr is updated (as requested by fl
ag
// EXEC_PROGRESS_STDOUT or EXEC_PROGRESS_STDERR respectively).
int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail, int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail,
ExecFlags flags, ExecFlags flags,
StreamSlot stream_progress_slot ) StreamSlot stream_progress_slot )
{ {
TimedSlot empty_timed_slot; TimedSlot empty_timed_slot;
return execute_command_internal( command, operationdetail, flags, stream_ progress_slot, empty_timed_slot ); return execute_command_internal(command, NULL, operationdetail, flags, st ream_progress_slot, empty_timed_slot);
} }
// Execute command, capture stdout and stderr to operation details and run progr
ess
// tracking callback periodically (when requested by flag EXEC_PROGRESS_TIMED).
int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail, int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail,
ExecFlags flags, ExecFlags flags,
TimedSlot timed_progress_slot ) TimedSlot timed_progress_slot )
{ {
StreamSlot empty_stream_slot; StreamSlot empty_stream_slot;
return execute_command_internal( command, operationdetail, flags, empty_s tream_slot, timed_progress_slot ); return execute_command_internal(command, NULL, operationdetail, flags, em pty_stream_slot, timed_progress_slot);
} }
int FileSystem::execute_command_internal( const Glib::ustring & command, Operati int FileSystem::execute_command_internal(const Glib::ustring& command, const cha
onDetail & operationdetail, r *input,
ExecFlags flags, OperationDetail& operationdetail,
StreamSlot stream_progress_slot, ExecFlags flags,
TimedSlot timed_progress_slot ) StreamSlot stream_progress_slot,
TimedSlot timed_progress_slot)
{ {
operationdetail.add_child( OperationDetail( command, STATUS_EXECUTE, FONT _BOLD_ITALIC ) ); operationdetail.add_child( OperationDetail( command, STATUS_EXECUTE, FONT _BOLD_ITALIC ) );
OperationDetail & cmd_operationdetail = operationdetail.get_last_child(); OperationDetail & cmd_operationdetail = operationdetail.get_last_child();
Glib::Pid pid; Glib::Pid pid;
int in = -1;
// set up pipes for capture // set up pipes for capture
int out, err; int out, err;
// spawn external process // spawn external process
running = true; running = true;
try { try {
Glib::spawn_async_with_pipes( Glib::spawn_async_with_pipes(
std::string( "." ), std::string( "." ),
Glib::shell_parse_argv( command ), Glib::shell_parse_argv( command ),
Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH, Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH,
sigc::ptr_fun(setup_child), sigc::ptr_fun(setup_child),
&pid, &pid,
0, (input != NULL) ? &in : 0,
&out, &out,
&err ); &err );
} catch (Glib::SpawnError &e) { } catch (Glib::SpawnError &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
cmd_operationdetail.add_child( OperationDetail( e.what(), STATUS_ ERROR, FONT_ITALIC ) ); cmd_operationdetail.add_child( OperationDetail( e.what(), STATUS_ ERROR, FONT_ITALIC ) );
return Utils::get_failure_status( e ); return Utils::get_failure_status( e );
} }
fcntl( out, F_SETFL, O_NONBLOCK ); fcntl( out, F_SETFL, O_NONBLOCK );
fcntl( err, F_SETFL, O_NONBLOCK ); fcntl( err, F_SETFL, O_NONBLOCK );
Glib::signal_child_watch().connect( sigc::mem_fun( *this, &FileSystem::st ore_exit_status ), pid ); Glib::signal_child_watch().connect( sigc::mem_fun( *this, &FileSystem::st ore_exit_status ), pid );
skipping to change at line 173 skipping to change at line 191
// Call progress tracking callback every 500 ms // Call progress tracking callback every 500 ms
timed_conn = Glib::signal_timeout().connect( sigc::bind( timed_pr ogress_slot, &cmd_operationdetail ), 500 ); timed_conn = Glib::signal_timeout().connect( sigc::bind( timed_pr ogress_slot, &cmd_operationdetail ), 500 );
outputcapture.connect_signal(); outputcapture.connect_signal();
errorcapture.connect_signal(); errorcapture.connect_signal();
cmd_operationdetail.signal_cancel.connect( cmd_operationdetail.signal_cancel.connect(
sigc::bind( sigc::bind(
sigc::ptr_fun( cancel_command ), sigc::ptr_fun( cancel_command ),
pid, pid,
flags & EXEC_CANCEL_SAFE ) ); flags & EXEC_CANCEL_SAFE ) );
if (input != NULL && in != -1)
{
// Write small amount of input to pipe to the child process. Lin
ux will
// always accept up to 4096 bytes without blocking. See pipe(7).
size_t len = strlen(input);
ssize_t written = write(in, input, len);
if (written == -1 || (size_t)written < len)
{
int e = errno;
std::cerr << "Write to child failed: " << Glib::strerror(
e) << std::endl;
cmd_operationdetail.add_child(OperationDetail("Write to c
hild failed: " + Glib::strerror(e),
STATUS_NONE
, FONT_ITALIC));
}
close(in);
}
Gtk::Main::run(); Gtk::Main::run();
if ( flags & EXEC_CHECK_STATUS ) if ( flags & EXEC_CHECK_STATUS )
cmd_operationdetail.set_success_and_capture_errors( exit_status = = 0 ); cmd_operationdetail.set_success_and_capture_errors( exit_status = = 0 );
close( out ); close( out );
close( err ); close( err );
if ( timed_conn.connected() ) if ( timed_conn.connected() )
timed_conn.disconnect(); timed_conn.disconnect();
cmd_operationdetail.stop_progressbar(); cmd_operationdetail.stop_progressbar();
return exit_status; return exit_status;
 End of changes. 10 change blocks. 
9 lines changed or deleted 54 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)