120 G4String absPath = GetAbsCommandDirPath(G4StrUtil::strip_copy(input));
123 if (absPath.length() == 0)
return nullptr;
124 if (absPath[
G4int(absPath.length() - 1)] !=
'/')
return nullptr;
125 if (absPath ==
"/")
return cmdTree;
127 for (std::size_t indx = 1; indx < absPath.length() - 1;) {
128 std::size_t jslash = absPath.find(
'/', indx);
129 if (jslash != G4String::npos) {
130 if (cmdTree !=
nullptr) cmdTree = cmdTree->
GetTree(
G4String(absPath.substr(0, jslash + 1)));
135 if (cmdTree ==
nullptr)
return nullptr;
143 if (apath.empty())
return apath;
148 if (apath[(std::size_t)0] !=
'/') bpath = currentCommandDir + apath;
152 for (std::size_t indx = 1; indx <= bpath.length() - 1;) {
153 std::size_t jslash = bpath.find(
'/', indx);
154 if (indx == jslash) {
158 if (jslash != G4String::npos) {
159 if (bpath.substr(indx, jslash - indx) ==
"..") {
160 if (absPath ==
"/") {
164 if (absPath.length() >= 2) {
165 absPath.erase(absPath.length() - 1);
166 auto jpre = absPath.rfind(
'/');
167 if (jpre != G4String::npos) absPath.erase(jpre + 1);
170 else if (bpath.substr(indx, jslash - indx) ==
".") {
173 if (jslash != indx || bpath[(
G4int)indx] !=
'/')
174 absPath += bpath.substr(indx, jslash - indx + 1);
229 G4String input = G4StrUtil::strip_copy(dir);
235 auto len = (
G4int)input.length();
236 if (! input.empty()) {
238 for (
G4int i = len - 1; i >= 0; --i) {
239 if (input[i] ==
'/') {
245 if (indx != -1) vpath = GetAbsCommandDirPath(input.substr(0, indx + 1));
246 if (indx != 0 || len != 1) vcmd = input.substr(indx + 1, len - indx - 1);
251 if (! vcmd.empty()) {
253 if (GetCommandTree(tmpstr) !=
nullptr) {
261 if (atree ==
nullptr) {
262 G4cout <<
"<" << input <<
">: No such directory" <<
G4endl;
272 if (Ndir == 0 && Ncmd == 0)
return;
275 for (
G4int idir = 1; idir <= Ndir; idir++) {
276 if (idir == 1 && lsColorFlag) stream += TermColorString[directoryColor];
279 if (candidate.empty()) {
280 if (vcmd.empty() || fpdir == inputpath) {
281 stream += GetCommandPathTail(fpdir);
287 if (fpdir.find(candidate, 0) == 0) {
288 stream += GetCommandPathTail(fpdir);
295 for (
G4int icmd = 1; icmd <= Ncmd; icmd++) {
296 if (icmd == 1 && lsColorFlag) stream += TermColorString[commandColor];
299 if (candidate.empty()) {
300 if (vcmd.empty() || fpcmd == inputpath) {
301 stream += GetCommandPathTail(fpcmd);
307 if (fpcmd.find(candidate, 0) == 0) {
308 stream += GetCommandPathTail(fpcmd);
315 if (! isMatch && candidate.empty())
316 G4cout <<
"<" << input <<
">: No such directory or command" << std::flush;
320 arrayString.
Show(nColumn);