Exemple #1
0
//*******************************************************************
// run_zip                                                   PRIVATE
//*******************************************************************
void QBtPackDialog::run_zip()
{
   const QChar space = ' ';

   QBtSystemCall sc;
   
   SelectionsSet::const_iterator it = data_.begin();
   const SelectionsSet::const_iterator end = data_.end();
   if( it == end ) return;
   
   dst_path_ = dst_dir_;
   if( !dst_path_.endsWith( QDir::separator() ) ) {
      dst_path_ += QDir::separator();
   }
   dst_path_ += name_;
   dst_path_ += ZIP_EXT;

   QString create_cmd = "zip";
   create_cmd += space;
   create_cmd += "-";
   create_cmd += ratio_->currentText();
   create_cmd += space;
   create_cmd += "-r";
   create_cmd += space;
   create_cmd += dst_path_;
   create_cmd += space;
   
   QString update_cmd = "zip";
   update_cmd += space;
   update_cmd += "-";
   update_cmd += ratio_->currentText();
   update_cmd += space;
   update_cmd += "-u";
   update_cmd += space;
   update_cmd += "-r";
   update_cmd += space;
   update_cmd += dst_path_;
   update_cmd += space;

   display_src( *it );
   sc.run( create_cmd + *it );
   
   ++it;
   while( it != end ) {
      display_src( *it );
      sc.run( update_cmd + *it );
      ++it;
   }
}
Exemple #2
0
//*******************************************************************
// md5_check                                                 PRIVATE
//*******************************************************************
void QBtWorkspace::md5_check()
{
    QBtView* src = 0;
    QBtView* dst = 0;
    if( !src_and_dst_view( src, dst ) ) return;

    SelectionsSet data = SelectionsSet();
    get_selections( src, data );
    if( data.size() != 1 ) return;

    const QString src_fpath = *data.begin();

    QBtSystemCall sc;
    sc.run( Md5Check.arg( QBtShared::quoted_fpath( src_fpath ) ) );
    const QString msg = sc.result();

    QMessageBox::information( this, tr( Md5 ), msg );
}
//*******************************************************************
// load_file                                                 PRIVATE
//*******************************************************************
void QBtFileEditor::load_file()
{
   static const QString cmd = "file -b -i \"%1\"";

   QApplication::setOverrideCursor( Qt::WaitCursor );      
   QBtSystemCall syscall;
   syscall.run( cmd.arg( path_ ) );
   const QString marker = syscall.result();

   const bool is_text = marker.startsWith( "text" ) ||
                        marker.contains( "script" ) ||
                        marker.contains( "perl" );
   
   if( is_text ) reload_file();
   QApplication::restoreOverrideCursor();

   if( !is_text ) {
      QMessageBox::information( this, tr( CAPTION ), tr( NOTEXT_FILE ).arg( path_ ) );
   }
}
Exemple #4
0
//*******************************************************************
// run_tar                                                   PRIVATE
//*******************************************************************
void QBtPackDialog::run_tar()
{
   const QChar space = ' ';

   QBtSystemCall sc;
   
   SelectionsSet::const_iterator it = data_.begin();
   const SelectionsSet::const_iterator end = data_.end();
   if( it == end ) return;
   
   QFileInfo fi( *it );
   const QString src_dir  = fi.absolutePath();
   
   dst_path_ = dst_dir_;
   if( !dst_path_.endsWith( QDir::separator() ) ) {
      dst_path_ += QDir::separator();
   }
   dst_path_ += name_;
   dst_path_ += TAR_EXT;

   QString create_cmd = "tar --verbose";
   create_cmd += space;
   create_cmd += "--create";
   create_cmd += space;
   create_cmd += "--directory=";
   create_cmd += src_dir;
   create_cmd += space;
   create_cmd += "--file=";
   create_cmd += dst_path_;
   create_cmd += space;
   
   QString update_cmd = "tar --verbose";
   update_cmd += space;
   update_cmd += "--update";
   update_cmd += space;
   update_cmd += "--directory=";
   update_cmd += src_dir;
   update_cmd += space;
   update_cmd += "--file=";
   update_cmd += dst_path_;
   update_cmd += space;
   
   fi.setFile( *it );
   display_src( *it );
   sc.run( create_cmd + fi.fileName() );
   
   ++it;
   while( it != end ) {
      fi.setFile( *it );
      display_src( *it );
      sc.run( update_cmd + fi.fileName() );
      ++it;
   }

   // Ewentualna kompresja.
   if( compression_->isChecked() ) {
      const bool is_gzip = ( USE_GZIP == compress_type_ );
      QString cmd = is_gzip ? "gzip -" : "bzip2 -";
      cmd += ratio_->currentText();
      cmd += space;
      cmd += dst_path_;
      sc.run( cmd );
      dst_path_ += ( is_gzip ? GZIP_EXT : BZIP2_EXT );
   }
}