ATLAS Offline Software
Loading...
Searching...
No Matches
DiskListLocal.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7//
8// includes
9//
10
12
13#include <memory>
14#include <TSystem.h>
17
18//
19// method implementations
20//
21
22namespace SH
23{
24 void DiskListLocal ::
25 testInvariant () const
26 {
27 }
28
29
30
31 DiskListLocal ::
32 DiskListLocal (const std::string& val_dir)
33 : m_dir (val_dir), m_prefix (val_dir), m_dirp (0)
34 {
35 RCU_NEW_INVARIANT (this);
36 }
37
38
39
40 DiskListLocal ::
41 DiskListLocal (const std::string& val_dir, const std::string& val_prefix)
42 : m_dir (val_dir), m_prefix (val_prefix), m_dirp (0)
43 {
44 RCU_NEW_INVARIANT (this);
45 }
46
47
48
49 DiskListLocal ::
50 ~DiskListLocal ()
51 {
53
54 if (m_dirp)
55 {
56 gSystem->FreeDirectory (m_dirp);
57 m_dirp = 0;
58 }
59 }
60
61
62
63 bool DiskListLocal ::
64 getNext ()
65 {
67
68 if (!m_dirp)
69 {
70 m_dirp = gSystem->OpenDirectory (m_dir.c_str());
71 if (!m_dirp)
72 RCU_THROW_MSG ("could not open directory " + m_dir);
73 }
74
75 const char *subresult = 0;
76 do
77 {
78 subresult = gSystem->GetDirEntry (m_dirp);
79 if (subresult == 0)
80 {
81 gSystem->FreeDirectory (m_dirp);
82 m_dirp = 0;
83 m_file.clear ();
84 return false;
85 }
86 } while (strcmp (subresult, ".") == 0 || strcmp (subresult, "..") == 0);
87 m_file = subresult;
88 return subresult;
89 }
90
91
92
93 std::string DiskListLocal ::
94 getPath () const
95 {
96 RCU_READ_INVARIANT (this);
97 return m_prefix + "/" + m_file;
98 }
99
100
101
102 DiskList *DiskListLocal ::
103 doOpenDir () const
104 {
105 RCU_READ_INVARIANT (this);
106
107 std::unique_ptr<DiskListLocal> result
108 (new DiskListLocal (m_dir + "/" + m_file, m_prefix + "/" + m_file));
109 result->m_dirp = gSystem->OpenDirectory (result->m_dir.c_str());
110 if (result->m_dirp)
111 return result.release();
112 return 0;
113 }
114
115
116
117 std::string DiskListLocal ::
118 getDirname () const
119 {
120 RCU_READ_INVARIANT (this);
121 return m_dir;
122 }
123}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:230
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:226
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53
std::string m_prefix
the directory from with to read actual files
std::string m_dir
the directory we are reading
void * m_dirp
the directory pointer used
DiskListLocal(const std::string &val_dir)
make the listing for the given directory
std::string m_file
the file we last fetched
DiskList()
standard constructor
Definition DiskList.cxx:38
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15