mana-core-clidcomps / src / ClassIDSvc.cxx

The default branch has multiple heads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#include <algorithm>  /* distance */
#include <cstdlib>    /* getenv */
#include <fstream>
#include <iostream>
#include <iterator>
#ifndef HAVE_NEW_IOSTREAMS      /*gnu-specific*/
#define BOOST_NO_STRINGSTREAM 1 /*FIXME should come from boost config */
#endif
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/replace.hpp>

#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/Incident.h"
#include "GaudiKernel/ModuleIncident.h"
#include "GaudiKernel/System.h"
#include "GaudiKernel/MsgStream.h"
#include "SGTools/CLIDRegistry.h"

#include "ClassIDSvc.h"

using namespace std;

using namespace Athena; //FIXME DirSearchPath

namespace {
  inline 
  void massage (string& s) {
    boost::trim(s); 
    boost::replace_all(s, string(";"), string());
  }

// HACK LIFTED FROM AthenaBaseComps/AthMsgStreamMacros.h to remove dep loop
#define ATH_MSG_LVL(lvl, x) \
   do {                                      \
     if (msg().level() <= lvl) {		     \
       msg() << lvl << x  << endmsg;		     \
     }                                       \
   } while (0)
 
#define ATH_MSG_VERBOSE(x) ATH_MSG_LVL(MSG::VERBOSE, x)
#define ATH_MSG_DEBUG(x)   ATH_MSG_LVL(MSG::DEBUG, x)

}


/// Standard Constructor
ClassIDSvc::ClassIDSvc(const std::string& name,ISvcLocator* svc)
  : Service(name,svc), m_outputFileName("NULL"),
    m_lastBegin(CLIDRegistry::begin()),
    m_lastEnd(CLIDRegistry::begin()),
    m_clidDBPath(System::getEnv("DATAPATH")),
    m_msg (msgSvc(), name)
{
  // Property Default values
  m_DBFiles.push_back("clid.db");
    
  // Get user's input	
  declareProperty("CLIDDBFiles",  m_DBFiles, 
		  "list of db files with (CLID, class_name) entries. Loaded at init in svc maps. Files are looked up in DATAPATH");
  declareProperty("OutputFileName",  m_outputFileName,
		  "path to clid.db file in which write at finalize entries in m_clidMap. Default ('NULL') is not to write output clid.db");

}

// Query the interfaces.
//   Input: riid, Requested interface ID
//          ppvInterface, Pointer to requested interface
//   Return: StatusCode indicating SUCCESS or FAILURE.
// N.B. Don't forget to release the interface after use!!!

StatusCode 
ClassIDSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) 
{
    if ( IClassIDSvc::interfaceID().versionMatch(riid) )    {
        *ppvInterface = (IClassIDSvc*)this;
    }
    else  {
	// Interface is not directly available: try out a base class
	return Service::queryInterface(riid, ppvInterface);
    }
    addRef();
    return StatusCode::SUCCESS;
}

StatusCode 
ClassIDSvc::initialize()
{
  msg() << MSG::INFO << "Initializing " << name() << " - package version " <<
    PACKAGE_VERSION << endreq ;

  if (!(Service::initialize().isSuccess())) {
    msg() << MSG::FATAL << "Could not initialize base class" << endmsg;
    return StatusCode::FAILURE;
  }

  // set up the incident service:
  IIncidentSvc* pIncSvc(0);
  const bool CREATEIF(true);
  if (!(service("IncidentSvc", pIncSvc, CREATEIF)).isSuccess()) {
    msg() << MSG::FATAL << "Could not locate IncidentSvc" << endmsg;
    return StatusCode::FAILURE;
  }
  assert( 0 != pIncSvc );

  const int PRIORITY = 100;
  pIncSvc->addListener(this, ModuleLoadedIncident::TYPE(), PRIORITY);
  pIncSvc->release();

  return fillDB();
}

bool ClassIDSvc::getRegistryEntries(const std::string& moduleName) {
  bool allOK(true);

  m_lastBegin = CLIDRegistry::begin();
  m_lastEnd = CLIDRegistry::end();
    
  //FIXME this is too simple and wasteful. One should modify CLIDRegistry
  //FIXME so that it returns only the entries corresponding to moduleName
  //FIXME OTH, as a quick hack it works
  CLIDRegistry::const_iterator iEntry(CLIDRegistry::begin());
  CLIDRegistry::const_iterator endEntry(CLIDRegistry::end());
  while (iEntry != endEntry) {
    const CLID clid                   = boost::get<0>(*iEntry);
    const std::string typeName        = boost::get<1>(*iEntry);
    const Athena::PackageInfo pkgInfo = boost::get<2>(*iEntry);
    const std::string typeInfoName    = boost::get<3>(*iEntry);
#ifndef NDEBUG		
    ATH_MSG_VERBOSE(
		    "reading [" 
		    << clid << ", "
		    << typeName << ", "
		    << pkgInfo << ", "
		    << typeInfoName << "]");
#endif
    allOK &= setTypePackageForID(clid, 
				 typeName,
				 pkgInfo, 
				 typeInfoName).isSuccess();
    ++iEntry;
  }
  
  if (allOK) {
    int nE = distance(CLIDRegistry::begin(), CLIDRegistry::end());
    msg() << MSG::INFO << " getRegistryEntries: read " << nE 
	  << " CLIDRegistry entries for module " << moduleName << endmsg;
  } else {
    msg() << MSG::ERROR 
	  << " getRegistryEntries: can not read  CLIDRegistry entries for module " 
	  << moduleName << endmsg;
  }

  return allOK;
}


inline
void ClassIDSvc::maybeRescan() const
{
  if (m_lastBegin != CLIDRegistry::begin() ||
      m_lastEnd != CLIDRegistry::end())
  {
    const_cast<ClassIDSvc*>(this)->getRegistryEntries ("ALL");
  }
}


void ClassIDSvc::handle(const Incident &inc) {
  const ModuleLoadedIncident& modInc(dynamic_cast<const ModuleLoadedIncident&>(inc));

  getRegistryEntries(modInc.module());
}


StatusCode 
ClassIDSvc::finalize()
{
  if (m_outputFileName != "NULL") {
    ofstream outfile( m_outputFileName.c_str());
    if ( !outfile ) {
      msg() << MSG::ERROR << "unable to open output CLIDDB file: " 
	    << m_outputFileName << endmsg;
      return StatusCode::RECOVERABLE;
    } else {
      //    ostream_iterator< pair<CLID, string> > os(outfile, ':');
      //    copy(m_clidMap.begin(), m_clidMap,end(), os);
      CLIDMap::const_iterator i(m_clidMap.begin()), iE(m_clidMap.end());
      while (i != iE) {
	const CLID clid = i->first;
	const std::string& typeName = i->second.first;
	const std::string& tiName   = i->second.second;
	outfile << clid << "; " << typeName;
	Athena::PackageInfo existInfo;
	if (getPackageInfoForID(i->first, existInfo).isSuccess()) {
	  outfile << "; " << existInfo;
	  outfile << "; " << tiName;
	}
	outfile	<< endl;
	++i;
      }
      msg() << MSG::INFO 
	    << "finalize: wrote " << m_clidMap.size() 
	    << " entries to output CLIDDB file: " << m_outputFileName << endmsg;
    }
    outfile.close();
  } //outputfilename != NULL
  return Service::finalize();
}

/// get next available CLID 
/// @throws std::runtime_error if no CLID can be allocated
CLID 
ClassIDSvc::nextAvailableID() const {
  maybeRescan();
  CLID valid(CLIDRegistry::MINCLID);
  while (valid <= CLIDRegistry::MAXCLID && isIDInUse(valid)) ++valid;
  if (valid > CLIDRegistry::MAXCLID) throw runtime_error("ClassIDSvc::nextAvailableID: none in range");
  return valid;
}

bool
ClassIDSvc::isIDInUse(const CLID& id ) const {
  maybeRescan();
  return 0 != m_clidMap.count(id);
}

bool
ClassIDSvc::isNameInUse(const string& name ) const {
  maybeRescan();
  return 0 != m_nameMap.count(name);
}

/// get type name associated with clID (if any)
StatusCode 
ClassIDSvc::getTypeNameOfID(const CLID& id, std::string& typeName) const {
  maybeRescan();
  StatusCode sc(StatusCode::FAILURE);
  CLIDMap::const_iterator iID = m_clidMap.find(id);
  if (iID != m_clidMap.end()) {
    typeName = iID->second.first;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getTypeNameOfID(" << id << ") type name is " << typeName);
#endif			
    sc = StatusCode::SUCCESS;
  } else {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getTypeNameOfID(" << id << ") no associated type name found ");
#endif			
  }
  return sc;
}

/// get type name associated with clID (if any)
StatusCode 
ClassIDSvc::getTypeInfoNameOfID(const CLID& id, 
				std::string& typeInfoName) const {
  maybeRescan();
  StatusCode sc(StatusCode::FAILURE);
  CLIDMap::const_iterator iID = m_clidMap.find(id);
  if (iID != m_clidMap.end()) {
    typeInfoName = iID->second.second;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getTypeInfoNameOfID(" << id << ") type-info name is " << typeInfoName);
#endif			
    sc = StatusCode::SUCCESS;
  } else {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getTypeInfoNameOfID(" << id << ") no associated type-info name found ");
#endif			
  }
  return sc;
}

/// get PackageInfo associated with clID (if any)
StatusCode 
ClassIDSvc::getPackageInfoForID(const CLID& id, Athena::PackageInfo& info) const {
  maybeRescan();
  StatusCode sc(StatusCode::FAILURE);
  PackageMap::const_iterator iID = m_packageMap.find(id);
  if (iID != m_packageMap.end()) {
    info = iID->second;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE("getPackageInfoForID(" << id << 
		    ") package name is " << info.name() << 
		    " package version is " << info.version());
#endif			
    sc = StatusCode::SUCCESS;
  } else {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getPackageInfoForID(" << id <<
		     ") no associated type name found ");
#endif			
  }
  return sc;
}
/// get id associated with type name (if any)
StatusCode 
ClassIDSvc::getIDOfTypeName(const std::string& typeName, CLID& id) const {
  maybeRescan();
  StatusCode sc(StatusCode::FAILURE);
  NameMap::const_iterator iID = m_nameMap.find(typeName);
  if (iID != m_nameMap.end()) {
    id = iID->second;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getIDOfTypeName(" << typeName << ") CLID is " << id);
#endif			
    sc = StatusCode::SUCCESS;
  } else {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getIDOfTypeName(" << typeName << ") no associated CLID found " );
#endif			
  }
  return sc;
}

/// get id associated with type-info name (if any)
StatusCode 
ClassIDSvc::getIDOfTypeInfoName(const std::string& typeInfoName,
				CLID& id) const {
  maybeRescan();
  StatusCode sc(StatusCode::FAILURE);
  NameMap::const_iterator iID = m_tiNameMap.find(typeInfoName);
  if (iID != m_tiNameMap.end()) {
    id = iID->second;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getIDOfTypeInfoName(" << typeInfoName << ") CLID is " << id);
#endif			
    sc = StatusCode::SUCCESS;
  } else {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "getIDOfTypeInfoName(" << typeInfoName << ") no associated CLID found ");
#endif			
  }
  return sc;
}

/// associate type name with clID
StatusCode 
ClassIDSvc::setTypePackageForID(const CLID& id, 
				const std::string& typeName,
				const Athena::PackageInfo& info,
				const std::string& typeInfoName) {
  if (id < CLIDRegistry::MINCLID || id > CLIDRegistry::MAXCLID) {
    msg() << MSG::FATAL << "setTypeNameForID: input id " << id 
	  << " is out of allowed range " << CLIDRegistry::MINCLID 
	  << " : " << CLIDRegistry::MAXCLID << endmsg;
    return StatusCode::FAILURE;
  }
  return uncheckedSetTypePackageForID(id, typeName, info, typeInfoName);
}

StatusCode 
ClassIDSvc::uncheckedSetTypePackageForID(const CLID& id, 
					 const std::string& typeName,
					 const Athena::PackageInfo& info,
					 const std::string& typeInfoName) {
  StatusCode sc(StatusCode::SUCCESS);
  //process "raw" typeName
  string procName(typeName);
  massage(procName);
  //first the id->name map
  string knownName("_____++++");
  if (getTypeNameOfID(id, knownName).isSuccess() && procName != knownName) {
    msg() << MSG::FATAL << "uncheckedSetTypePackageForID: " << info <<
      " can not set type name <" << procName << "> for CLID " <<
      id << ": Known name for this ID <" << knownName << '>';
    Athena::PackageInfo existInfo;
    if (getPackageInfoForID(id, existInfo).isSuccess()) {
      msg() << MSG::FATAL 
	    << " It was set by " << existInfo;
    }
    msg() << MSG::ERROR << endreq;
    sc = StatusCode::FAILURE;
  } else if (procName == knownName) {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: type name <" << procName <<
		    "> already set for CLID " << id);
    Athena::PackageInfo existInfo;
    if (getPackageInfoForID(id, existInfo).isSuccess()) {
      ATH_MSG_VERBOSE( " It was set by " << existInfo );
    }
#endif			
  } 
  if (!sc.isSuccess()) return StatusCode::FAILURE;

  //now the name->id map
  CLID knownID(0);
  if (getIDOfTypeName(procName, knownID).isSuccess() && id != knownID) {
    msg() << MSG::ERROR << "uncheckedSetTypePackageForID: " << info << 
      " can not set CLID <" << id << "> for type name " <<
      procName << ": Known CLID for this name <" << knownID << '>' ;
    Athena::PackageInfo existInfo;
    if (getPackageInfoForID(knownID, existInfo).isSuccess()) {
      msg() << MSG::ERROR 
	    << " It was set by " << existInfo; 
    }
    msg() << MSG::ERROR << endreq;
    sc = StatusCode::FAILURE;
  } else if (id == knownID) {
#ifndef NDEBUG		
    ATH_MSG_VERBOSE( "uncheckedSetTypePackageForID: CLID <" << id <<
		     "> already set for type name " << procName );
    Athena::PackageInfo existInfo;
    if (getPackageInfoForID(id, existInfo).isSuccess()) {
      ATH_MSG_VERBOSE( " It was set by " << existInfo);
    }
#endif			
  } 
//   //finally the id->package map
//   Athena::PackageInfo knownInfo;
//   if (getPackageInfoForID(id, knownInfo).isSuccess() && info != knownInfo) {
//     msg() << MSG::ERROR 
// 	<< "uncheckedSetTypePackageForID: can not set package info <" << info
// 	<< "> for CLID " << id
// 	<< ": Known info for this CLID <" << knownInfo << '>' << endreq;
//     sc = StatusCode::FAILURE;
//   } else if (info == knownInfo) {
// #ifndef NDEBUG		
//     msg() << MSG::VERBOSE
// 	<< "uncheckedSetTypePackageForID: package info <" << info
// 	<< "> already set for CLID " << id<< endreq;
// #endif			
//   } else {
    const std::string procTiName = typeInfoName.empty() 
      ? procName
      : typeInfoName;
    m_clidMap[id] = std::make_pair(procName, procTiName);
    m_nameMap[procName] = id;
    // FIXME: should we also check for ti-name<=>clid duplicates ?
    m_tiNameMap[procTiName] = id;
    m_packageMap[id] = info;
#ifndef NDEBUG		
    ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: set type name <" <<
		    procName << "> for CLID " << id);
#endif					
    //  }
  return sc;
}
bool
ClassIDSvc::processCLIDDB(const char* fileName) {
  maybeRescan();
  bool allOK(true);
  ifstream ifile(fileName);
  if (!ifile) {
    msg() << MSG::WARNING << "processCLIDDB: unable to open " << fileName <<endmsg;
  } else {
#ifndef NDEBUG
    unsigned int newEntries(0);
#endif
    string line;
    while (allOK && std::getline(ifile, line)) {
      //not yet if ("#" == line.substr(0,0)) continue; //skip comments
      //split the record in 2 fields:	
      //      cout << "record " << line << endl;
      typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
      Tokenizer tokens(line, boost::char_separator<char>(";"));
      Tokenizer::iterator iToken(tokens.begin()), tEnd(tokens.end());
      long id(-1);
      const std::size_t columns = distance (iToken, tEnd);
      if (columns == 2  || columns == 3 || columns == 4) {
	string massTok(*iToken++);
	massage(massTok);
	try {
	  id = boost::lexical_cast<long>(massTok);
	  //	  cout << "id " << id << endl;
	} catch (boost::bad_lexical_cast e) { 
	  msg() << MSG::ERROR << "processCLIDDB: Can't cast ["  
		<< massTok << "] to long (clid)" << endmsg;
	  allOK=false;
	  break;
	}
	string typeName(*iToken++);
	massage(typeName);
	//	cout << "typeName " << typeName << endl;

	
	string sinfo;
	if (columns>=3) { 
	  sinfo=*iToken++; 
	  massage(sinfo);
	} else { sinfo = "UNKNOWN-00-00-00"; }
	Athena::PackageInfo info(sinfo);

	//	cout << "info " << info << endl;

	string typeInfoName;
	if (columns>=4) { 
	  massage(typeInfoName = *iToken++);
	} else { typeInfoName = typeName; }
	  
	// cout << "typeInfo " << typeInfoName << endl;

	if ((allOK = !typeName.empty())) {
	  if (uncheckedSetTypePackageForID(id, 
					   typeName,
					   info,
					   typeInfoName).isSuccess()) {
#ifndef	 NDEBUG
	    ATH_MSG_VERBOSE( "processCLIDDB(" << fileName << 
			     ")\n    added entry for CLID <" << id << 
			     "> type name <" << typeName << '>' );
	    ++newEntries;
#endif	
	  }
	}
      }
    } //while records
    if (!allOK) {
      msg() << MSG::ERROR << "processCLIDDB: processing record " << line 
	    << " 	from CLIDDB file: " << fileName << endmsg;
    } else {
#ifndef NDEBUG
      ATH_MSG_DEBUG( "processCLIDDB: read " << newEntries << 
		     " entries from CLIDDB file: " << fileName);
#endif	
    }
    ifile.close();
  } //input file open
      
  return allOK;
}

void 
ClassIDSvc::dump() const {
  maybeRescan();
  msg() << MSG::INFO << "dump: in memory" << endmsg;
    CLIDMap::const_iterator i(m_clidMap.begin()), iE(m_clidMap.end());
    while (i != iE) {
      const CLID clid = i->first;
      const std::string& typeName = i->second.first;
      msg() << MSG::INFO 
	    << "CLID: "<< clid
	    << " - type name: " << typeName;
      Athena::PackageInfo info;
      if (getPackageInfoForID(clid, info).isSuccess()) {
	msg() << MSG::INFO 
	      << "- Package "<< info; 
      }
      msg() << MSG::INFO << '\n';
      ++i;
    }
    msg() << MSG::INFO << "------------------------------" << endreq;
}

StatusCode
ClassIDSvc::fillDB() {
  // Process the various clid dbs according to user's request
  vector< string >::const_iterator f(m_DBFiles.begin()), fE(m_DBFiles.end());
  bool allOK(true);
  while (f != fE) {
    DirSearchPath::path clidDB(*f++, boost::filesystem::no_check);
    const std::string& clidDBFileName(clidDB.native_file_string());
    if (clidDB.is_complete()) {
      allOK = processCLIDDB(clidDBFileName.c_str());
    } else {
      std::list<DirSearchPath::path> paths(m_clidDBPath.find_all(clidDBFileName));
      if (paths.empty()) {
	msg() << MSG::WARNING 
	      << "Could not resolve clid DB path " << clidDBFileName 
	      << " using DATAPATH [" << System::getEnv("DATAPATH") 
	      << "] ----- SKIPPING" << endmsg;
      } else {
	std::list<DirSearchPath::path>::const_iterator p(paths.begin()), pe(paths.end());
	while (p!=pe) allOK &= processCLIDDB((*p++).native_file_string().c_str());
      }
    }
  }
  return (getRegistryEntries("ALL") && allOK) ?  
    StatusCode::SUCCESS :
    StatusCode::FAILURE;
}

StatusCode
ClassIDSvc::reinitialize() {
  msg() << MSG::INFO << "RE-initializing " << name() 
	<< " - package version " << PACKAGE_VERSION << endreq ;  
  return fillDB();
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.