40 :currentDirectory(
"/")
50 G4String rawCommandLine = aCommandLine;
51 if(rawCommandLine.
isNull()||rawCommandLine(0)==
'\0')
return rawCommandLine;
55 size_t i = commandLine.
index(
" ");
56 if( i != std::string::npos )
58 commandString = commandLine(0,i);
59 parameterString =
" ";
60 parameterString += commandLine(i+1,commandLine.length()-(i+1));
63 { commandString = commandLine; }
66 = ModifyPath( commandString )+parameterString;
67 return fullPathCommandLine;
72 return currentDirectory;
79 G4String newDirectory = ModifyPath( newPrefix );
80 if( newDirectory( newDirectory.length() - 1 ) !=
'/' )
81 { newDirectory +=
"/"; }
84 currentDirectory = newDirectory;
92 G4String targetDir = ModifyPath( theDir );
93 if( targetDir( targetDir.length()-1 ) !=
'/' )
96 if( targetDir ==
"/" )
99 while( idx < targetDir.length()-1 )
101 size_t i = targetDir.
index(
"/",idx);
102 comTree = comTree->
GetTree(targetDir.substr(0,i+1).c_str());
103 if( comTree == NULL )
112 G4String rawCommandLine = commandName;
115 size_t i = commandLine.
index(
" ");
116 if( i != std::string::npos )
117 { commandString = commandLine(0,i); }
119 { commandString = commandLine; }
121 G4String targetCom = ModifyPath(commandString);
127 if( tempPath.length() == 0 )
return tempPath;
132 if( tempPath(0) ==
'/') newPath = tempPath;
133 else newPath = currentDirectory + tempPath;
137 size_t idx = newPath.find(
"/./");
138 if( idx == G4String::npos)
break;
139 newPath.erase(idx,2);
143 size_t idx = newPath.find(
"/../");
144 if( idx == G4String::npos)
break;
149 size_t idx2 = newPath.find_last_of(
'/', idx-1);
150 if(idx2 != G4String::npos) newPath.erase(idx2, idx-idx2+3);
154 if(newPath(newPath.size()-3,3) ==
"/..") {
155 if( newPath.size() == 3) {
158 size_t idx = newPath.find_last_of(
'/', newPath.size()-4);
159 if(idx != G4String::npos) newPath.erase(idx+1);
162 if(newPath(newPath.size()-2,2) ==
"/.") newPath.erase(newPath.size()-1,1);
166 size_t idx = newPath.find(
"//");
167 if( idx == G4String::npos)
break;
168 newPath.erase(idx,1);
178 G4String rawCommandLine = commandName;
180 size_t i = commandLine.
index(
" ");
181 if( i != std::string::npos )
return rawCommandLine;
183 G4String commandString = commandLine;
184 G4String targetCom = ModifyPath(commandString);
187 if(value==
"")
return rawCommandLine;
194 return aTree-> CompleteCommandPath(aCommandPath);
206 if(aCommand.length()<2)
return;
210 switch(commandStatus) {
214 G4cerr <<
"command not found: " <<
"\"" << aCommand <<
"\"" <<
G4endl;
217 G4cerr <<
"illegal application state -- command refused:" <<
"\"" << aCommand <<
"\"" <<
G4endl;
223 G4cerr <<
"command refused (" << commandStatus <<
"):" <<
"\"" << aCommand <<
"\"" <<
G4endl;
239 if( command(0) ==
'#' ) {
243 }
else if( command ==
"ls" || command(0,3) ==
"ls " ) {
247 }
else if( command ==
"pwd" ) {
249 G4cout <<
"Current Working Directory : "
252 }
else if( command ==
"cd" || command(0,3) ==
"cd ") {
256 }
else if( command ==
"help" || command(0,5) ==
"help ") {
260 }
else if( command(0) ==
'?' ) {
264 }
else if( command ==
"hist" || command ==
"history") {
267 for(
G4int i=0;i<nh;i++) {
271 }
else if( command(0) ==
'!' ) {
273 G4String ss = command(1,command.length()-1);
276 std::istringstream is(tt);
284 G4cerr <<
"history " << vl <<
" is not found." <<
G4endl;
287 }
else if( command ==
"exit" ) {
289 if( exitPause ==
false) {
291 G4cout <<
"Please abort it using \"/run/abort\" command first" <<
G4endl;
292 G4cout <<
" and use \"continue\" command until the application" <<
G4endl;
298 }
else if( command ==
"cont" || command ==
"continue"){
313 G4String comString = newCommand.substr(1,newCommand.length()-1);
317 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
324 if( newCommand.length() <= 3 ) {
327 G4String aNewPrefix = newCommand.substr(3, newCommand.length()-3);
331 G4cout <<
"directory <" << prefix <<
"> not found." <<
G4endl;
338 if( newCommand.length() <= 3 ) {
341 G4String newPrefix = newCommand.substr(3, newCommand.length()-3);
345 if( commandTree == NULL ) {
346 G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl;
356 size_t i = newCommand.
index(
" ");
357 if( i != std::string::npos )
359 G4String newValue = newCommand.substr(i+1, newCommand.length()-(i+1));
363 if( theCommand != NULL )
370 G4cout <<
"Command <" << newValue <<
" is not found." <<
G4endl;
378 size_t prefixIndex = 1;
380 while( prefixIndex < prefix.length()-1 )
382 size_t ii = prefix.
index(
"/",prefixIndex);
395 G4cout << G4endl <<
"Not a number, once more" <<
G4endl;
398 if( iFloor < (
size_t)-j ) iFloor = 0;
410 if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
417 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
G4UIcommandTree * FindDirectory(const char *dirName) const
G4int GetNumberOfHistory() const
virtual G4bool GetHelpChoice(G4int &)=0
G4String GetPreviousCommand(G4int i) const
void ChangeDirectoryCommand(const G4String &)
virtual void ExitHelp() const =0
void TerminalHelp(const G4String &)
G4UIcommand * FindPath(const char *commandPath) const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4UIcommand * GetCommand(G4int i)
G4int GetTreeEntry() const
G4String FindMatchingPath(G4UIcommandTree *, const G4String &)
G4String Complete(const G4String &)
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
void ListCurrentWithNum() const
virtual void ExecuteCommand(const G4String &)
G4bool ChangeDirectory(const char *newDir)
G4String GetCurrentValues(const char *aCommand)
G4String ModifyToFullPathCommand(const char *aCommandLine) const
G4UIcommandTree * GetTree() const
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)
void ShowCurrent(const G4String &) const
void ListDirectory(const G4String &) const
const XML_Char int const XML_Char * value
G4String GetCurrentWorkingDirectory() const
G4UIcommand * FindCommand(const char *commandName) const
G4int ApplyCommand(const char *aCommand)
G4GLOB_DLL std::ostream G4cerr