-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathvtkDICOMFileDirectory.h
145 lines (117 loc) · 4.06 KB
/
vtkDICOMFileDirectory.h
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
/*=========================================================================
Program: DICOM for VTK
Copyright (c) 2012-2024 David Gobbi
All rights reserved.
See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef vtkDICOMFileDirectory_h
#define vtkDICOMFileDirectory_h
#include "vtkSystemIncludes.h"
#include "vtkDICOMModule.h" // For export macro
#include "vtkDICOMConfig.h" // For configuration details
#include <string> // Interface type
//! A class that provides directory listings.
class VTKDICOM_EXPORT vtkDICOMFileDirectory
{
public:
//! The access mode (input or output).
enum Mode
{
In,
Out
};
//! Error codes.
enum Code
{
Good, // no error
UnknownError, // unspecified error
AccessDenied, // file permission error
Reserved,
ImpossiblePath, // part of the path doesn't exist or goes through a file
FileNotFound, // requested file (or directory) doesn't exist
OutOfSpace // disk full or quota exceeded
};
//@{
//! Construct the object from a directory name.
/*!
* This causes the directory to be read. Use GetError() to check whether
* the read was successful.
*/
vtkDICOMFileDirectory(const char *dirname);
//! Copy constructor.
vtkDICOMFileDirectory(const vtkDICOMFileDirectory&);
//! Destruct the object.
~vtkDICOMFileDirectory();
//@}
//@{
//! Return an error indicator (zero if no error).
int GetError() { return this->Error; }
//@}
//@{
//! Get the number of files and subdirectories in the directory.
int GetNumberOfEntries() { return this->NumberOfEntries; }
//! Get the name of the ith file or subdirectory.
/*!
* The entries do not include "." or "..".
*/
const char *GetEntry(int i);
//! Check if the list entry is a directory.
bool IsDirectory(int i);
//! Check if the list entry is special (a device, socket, or pipe).
bool IsSpecial(int i);
//! Check if the list entry is a symbolic link.
bool IsSymlink(int i);
//! Check if the list entry is a symbolic link that is broken.
/*!
* A link is broken if it points to a location that does not exist,
* or to a location that is in a directory that cannot be accessed.
* IsSymlink() will always be true if IsBroken() is true.
*/
bool IsBroken(int i);
//! Check if the list entry has an attribute that marks it as hidden.
bool IsHidden(int i);
//@}
//@{
//! Test a directory for accessibility (static method).
/*!
* The mode should be "In" or "Out" to indicate whether you intend to
* read from or write to the directory. A return value of zero means
* the directory can be accessed, otherwise an error code will be
* returned.
*/
static int Access(const char *dirname, Mode mode);
//! Create a new directory with default permissions (static method).
/*!
* This will create any intermediate directories, as well. The return
* value is zero for success. Otherwise, one of the error codes is
* returned.
*/
static int Create(const char *dirname);
//@}
//@{
//! Assignment operator.
vtkDICOMFileDirectory& operator=(const vtkDICOMFileDirectory&);
//@}
private:
//! Add a directory entry.
void AddEntry(const char *name, unsigned short flags, unsigned short mask);
//! Call stat() on a file to set flags
void StatEntry(int i);
//! Call lstat() on a file to set flags
void LinkStatEntry(int i);
struct Entry;
static const unsigned int TypeDirectory = 1;
static const unsigned int TypeSpecial = 2;
static const unsigned int TypeSymlink = 4;
static const unsigned int TypeBroken = 8;
static const unsigned int TypeHidden = 16;
std::string Name;
int Error;
int NumberOfEntries;
Entry *Entries;
};
#endif /* vtkDICOMFileDirectory_h */
// VTK-HeaderTest-Exclude: vtkDICOMFileDirectory.h