メインページ   モジュール   名前空間一覧   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TListCommand.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TListCommand.cc,v 1.4 2004/03/07 10:30:28 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TListCommand.cc,v $
00005 //  Revision 1.4  2004/03/07 10:30:28  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.3  2003/10/06 17:02:37  goiwai
00010 //  *** empty log message ***
00011 //
00012 //  Revision 1.2  2003/07/30 16:17:31  goiwai
00013 //  ファイルにコミットログをつけることにしました.
00014 //
00015 // =====================================================================
00016 #include "TListCommand.hh"
00017 #include "TRunManager.hh"
00018 #include "TUserInterface.hh"
00019 #include "TCommandTable.hh"
00020 
00021 static const Tstring _name = "ls";
00022 static const Tstring _desc = "list up.\nexample> ls\nexample> ls [command|directory]";
00023 
00024 TListCommand::TListCommand( TRunManager* manager )
00025   : TCommand( manager, _name, _desc )
00026 {;}
00027 
00028 TListCommand::~TListCommand()
00029 {;}
00030 
00031 Tvoid TListCommand::Execute( const TstringList& arguments )
00032 {
00033   if ( arguments.size() == 0 ) {
00034     normal();
00035   } else if ( arguments.size() == 1 ) {
00036     detail( arguments[ 0 ] );
00037   } else {
00038     Tcerr << "TListCommand::Execute: invalid arguments, " << Tendl;
00039     for ( Tsize_t i = 0; i < arguments.size(); i ++ ) {
00040       Tcerr << arguments[ i ];
00041       if ( i == arguments.size() - 1 ) {
00042         Tcerr << "." << Tendl;
00043       } else {
00044         Tcerr << ", ";
00045       }
00046     }
00047     ShowCommandDetail();
00048   }
00049 
00050   return;
00051 }
00052 
00053 Tvoid TListCommand::normal() const
00054 {
00055   TUserInterface* ui = theRunManager -> GetUserInterface();
00056   if ( ui ) {
00057     Tint column = ui -> GetNumberOfColumns();
00058     Tstring cwd = ui -> GetCurrentWorkingDirectory();
00059     const TCommandTable& table = ui -> GetCommandTable();
00060     table.List( column, table.Sort( cwd ) );
00061   }
00062   return;
00063 }
00064 
00065 Tvoid TListCommand::detail( const Tstring& path ) const
00066 {
00067   TUserInterface* ui = theRunManager -> GetUserInterface();
00068   if ( ui ) {
00069     Tstring abspath = ui -> ModifyPath( path );
00070     const TCommandTable& table = ui -> GetCommandTable();
00071 
00072     Tbool iscom = table.AlreadyExist( abspath );
00073     Tbool isdir = table.AlreadyExistDirectory( abspath );
00074 
00075     if ( iscom == Ttrue && isdir == Tfalse ) {
00076       TstringList args;
00077       args.push_back( abspath );
00078       ui -> ExecuteCommand( "help", args );
00079     } else if ( iscom == Tfalse && isdir == Ttrue ) {
00080       TstringList args;
00081       args.push_back( abspath );
00082 
00083       Tstring backdir = ui -> GetCurrentWorkingDirectory();
00084 
00085       ui -> ExecuteCommand( "cd", args );
00086       ui -> ExecuteCommand( "ls" );
00087 
00088       args.clear();
00089       args.push_back( backdir );
00090       ui -> ExecuteCommand( "cd", args );
00091     } else {
00092       ui -> NotFoundCommand( path );
00093     }
00094 
00095   }
00096   return;
00097 }
00098 
00099 #ifdef __CLDAQ_ROOT_DLL
00100     ClassImp(TListCommand)
00101 #endif


CLDAQ - a Class Library for DataAcQuisition (Version 1.14.3)
Go IWAI -- goiwai at users.sourceforge.jp