Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larpandoracontent
larpandoracontent
LArHelpers
LArFileHelper.cc
Go to the documentation of this file.
1
/**
2
* @file larpandoracontent/LArHelpers/LArFileHelper.cc
3
*
4
* @brief Implementation of the file helper class.
5
*
6
* $Log: $
7
*/
8
9
#include "Helpers/XmlHelper.h"
10
11
#include "
larpandoracontent/LArHelpers/LArFileHelper.h
"
12
13
#include <cstdlib>
14
#include <sys/stat.h>
15
16
using namespace
pandora
;
17
18
namespace
lar_content
19
{
20
21
std::string
LArFileHelper::FindFileInPath(
const
std::string
&unqualifiedFileName,
const
std::string
&environmentVariable,
const
std::string
&delimiter)
22
{
23
StringVector
filePaths;
24
const
char
*
const
pFilePathList(
std::getenv
(environmentVariable.c_str()));
25
26
if
(pFilePathList)
27
XmlHelper::TokenizeString(pFilePathList, filePaths, delimiter);
28
29
// Always test unqualified file name too
30
filePaths.push_back(
""
);
31
32
for
(
const
std::string
&filePath : filePaths)
33
{
34
const
std::string
qualifiedFileNameAttempt(filePath +
"/"
+ unqualifiedFileName);
35
struct
stat
fileInfo;
36
37
if
(0 ==
stat
(qualifiedFileNameAttempt.c_str(), &fileInfo))
38
return
qualifiedFileNameAttempt;
39
}
40
41
std::cout <<
"Unable to find file "
<< unqualifiedFileName <<
" in any path specified by environment variable "
<< environmentVariable
42
<<
", delimiter "
<< delimiter <<
std::endl
;
43
throw
StatusCodeException(STATUS_CODE_NOT_FOUND);
44
}
45
46
}
// namespace lar_content
lar_content
Definition:
CheatingBeamParticleIdTool.cc:18
string
std::string string
Definition:
nybbler.cc:12
python.larbatch_posix.stat
def stat(path)
Definition:
larbatch_posix.py:482
pandora
Definition:
ILArPandora.h:14
cet::getenv
std::string getenv(std::string const &name)
Definition:
getenv.cc:15
LArFileHelper.h
Header file for the file helper class.
StringVector
std::vector< string > StringVector
Definition:
fcldump.cxx:29
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11