vtk-dicom  0.8.14
vtkDICOMFileDirectory.h
1 /*=========================================================================
2 
3  Program: DICOM for VTK
4 
5  Copyright (c) 2012-2022 David Gobbi
6  All rights reserved.
7  See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef vtkDICOMFileDirectory_h
15 #define vtkDICOMFileDirectory_h
16 
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h" // For export macro
19 #include "vtkDICOMConfig.h" // For configuration details
20 
21 #include <string> // Interface type
22 
24 class VTKDICOM_EXPORT vtkDICOMFileDirectory
25 {
26 public:
28  enum Mode
29  {
30  In,
31  Out
32  };
33 
35  enum Code
36  {
37  Good, // no error
38  UnknownError, // unspecified error
39  AccessDenied, // file permission error
40  Reserved,
41  ImpossiblePath, // part of the path doesn't exist or goes through a file
42  FileNotFound, // requested file (or directory) doesn't exist
43  OutOfSpace // disk full or quota exceeded
44  };
45 
47 
52  vtkDICOMFileDirectory(const char *dirname);
53 
56 
60 
62  int GetError() { return this->Error; }
65 
67  int GetNumberOfEntries() { return this->NumberOfEntries; }
69 
71 
74  const char *GetEntry(int i);
75 
77  bool IsDirectory(int i);
78 
80  bool IsSpecial(int i);
81 
83  bool IsSymlink(int i);
84 
86 
91  bool IsBroken(int i);
92 
94  bool IsHidden(int i);
96 
98 
105  static int Access(const char *dirname, Mode mode);
106 
108 
113  static int Create(const char *dirname);
115 
117  vtkDICOMFileDirectory& operator=(const vtkDICOMFileDirectory&);
120 
121 private:
123  void AddEntry(const char *name, unsigned short flags, unsigned short mask);
124 
126  void StatEntry(int i);
127 
129  void LinkStatEntry(int i);
130 
131  struct Entry;
132  static const unsigned int TypeDirectory = 1;
133  static const unsigned int TypeSpecial = 2;
134  static const unsigned int TypeSymlink = 4;
135  static const unsigned int TypeBroken = 8;
136  static const unsigned int TypeHidden = 16;
137 
138  std::string Name;
139  int Error;
140  int NumberOfEntries;
141  Entry *Entries;
142 };
143 
144 #endif /* vtkDICOMFileDirectory_h */
145 // VTK-HeaderTest-Exclude: vtkDICOMFileDirectory.h
A class that provides directory listings.
Definition: vtkDICOMFileDirectory.h:25
bool IsSpecial(int i)
Check if the list entry is special (a device, socket, or pipe).
bool IsBroken(int i)
Check if the list entry is a symbolic link that is broken.
Code
Error codes.
Definition: vtkDICOMFileDirectory.h:36
bool IsSymlink(int i)
Check if the list entry is a symbolic link.
bool IsDirectory(int i)
Check if the list entry is a directory.
~vtkDICOMFileDirectory()
Destruct the object.
static int Create(const char *dirname)
Create a new directory with default permissions (static method).
const char * GetEntry(int i)
Get the name of the ith file or subdirectory.
vtkDICOMFileDirectory(const vtkDICOMFileDirectory &)
Copy constructor.
static int Access(const char *dirname, Mode mode)
Test a directory for accessibility (static method).
vtkDICOMFileDirectory(const char *dirname)
Construct the object from a directory name.
bool IsHidden(int i)
Check if the list entry has an attribute that marks it as hidden.
Mode
The access mode (input or output).
Definition: vtkDICOMFileDirectory.h:29