00001
00002
00003
00004 #include "TFndEnv.h"
00005
00006 #include <TVirtualMutex.h>
00007 #include <TSystem.h>
00008
00009 #include "FROOT.h"
00010
00011 static TVirtualMutex *fgMutex = NULL;
00012
00013 TFndEnv *TFndEnv::Instance()
00014 {
00015 R__LOCKGUARD2(fgMutex);
00016 static TFndEnv instance;
00017 return &instance;
00018 }
00019
00020 TString TFndEnv::FetchDefaultRcFilename() const
00021 {
00022 const char *topLevel = gSystem->Getenv("FROOTSYS");
00023 if (!topLevel) {
00024 Warning("TFndEnv", "Environment variable FROOTSYS missing");
00025 return TString();
00026 }
00027 return FROOT::ConcatFileName(topLevel, ".frootrc");
00028 }
00029
00030 TFndEnv::TFndEnv() : TEnv(FetchDefaultRcFilename())
00031 {
00032 }
00033
00034 TFndEnv::~TFndEnv()
00035 {
00036 }
00037
00038 Int_t TFndEnv::GetValue(const char *name, Int_t dflt)
00039 {
00040 return TEnv::GetValue(name, dflt);
00041 }
00042
00043 Double_t TFndEnv::GetValue(const char *name, Double_t dflt)
00044 {
00045 return TEnv::GetValue(name, dflt);
00046 }
00047
00048 const char *TFndEnv::GetValue(const char *name, const char *dflt)
00049 {
00050 return TEnv::GetValue(name, dflt);
00051 }
00052
00053 const char *TFndEnv::GetValue(const char *name, const char *dflt, const char *envVar)
00054 {
00055 const char *s;
00056 if (envVar && (s = gSystem->Getenv(envVar)) != NULL)
00057 return s;
00058 return TEnv::GetValue(name, dflt);
00059 }