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
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10// Please feel free to contact me (krumnack@iastate.edu) for bug
11// reports, feature suggestions, praise and complaints.
12
13
14//
15// includes
16//
17
19
20#include <memory>
21#include <TSystem.h>
24
25//
26// method implementations
27//
28
29namespace SH
30{
31 void DiskListLocal ::
32 testInvariant () const
33 {
34 }
35
36
37
38 DiskListLocal ::
39 DiskListLocal (const std::string& val_dir)
40 : m_dir (val_dir), m_prefix (val_dir), m_dirp (0)
41 {
42 RCU_NEW_INVARIANT (this);
43 }
44
45
46
47 DiskListLocal ::
48 DiskListLocal (const std::string& val_dir, const std::string& val_prefix)
49 : m_dir (val_dir), m_prefix (val_prefix), m_dirp (0)
50 {
51 RCU_NEW_INVARIANT (this);
52 }
53
54
55
56 DiskListLocal ::
57 ~DiskListLocal ()
58 {
60
61 if (m_dirp)
62 {
63 gSystem->FreeDirectory (m_dirp);
64 m_dirp = 0;
65 }
66 }
67
68
69
70 bool DiskListLocal ::
71 getNext ()
72 {
74
75 if (!m_dirp)
76 {
77 m_dirp = gSystem->OpenDirectory (m_dir.c_str());
78 if (!m_dirp)
79 RCU_THROW_MSG ("could not open directory " + m_dir);
80 }
81
82 const char *subresult = 0;
83 do
84 {
85 subresult = gSystem->GetDirEntry (m_dirp);
86 if (subresult == 0)
87 {
88 gSystem->FreeDirectory (m_dirp);
89 m_dirp = 0;
90 m_file.clear ();
91 return false;
92 }
93 } while (strcmp (subresult, ".") == 0 || strcmp (subresult, "..") == 0);
94 m_file = subresult;
95 return subresult;
96 }
97
98
99
100 std::string DiskListLocal ::
101 getPath () const
102 {
103 RCU_READ_INVARIANT (this);
104 return m_prefix + "/" + m_file;
105 }
106
107
108
109 DiskList *DiskListLocal ::
110 doOpenDir () const
111 {
112 RCU_READ_INVARIANT (this);
113
114 std::unique_ptr<DiskListLocal> result
115 (new DiskListLocal (m_dir + "/" + m_file, m_prefix + "/" + m_file));
116 result->m_dirp = gSystem->OpenDirectory (result->m_dir.c_str());
117 if (result->m_dirp)
118 return result.release();
119 return 0;
120 }
121
122
123
124 std::string DiskListLocal ::
125 getDirname () const
126 {
127 RCU_READ_INVARIANT (this);
128 return m_dir;
129 }
130}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
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:45
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15