vtk-dicom  0.8.17
Public Types | Public Member Functions | Static Public Member Functions | List of all members
vtkDICOMFile Class Reference

A class that provides basic input/output operations. More...

#include <vtkDICOMFile.h>

Public Types

enum  Mode { In , Out }
 The file mode (input or output).
 
enum  Code {
  Good , UnknownError , AccessDenied , FileIsDirectory ,
  ImpossiblePath , FileNotFound , OutOfSpace
}
 Error codes.
 
typedef unsigned long long Size
 Typedef for a file size.
 

Public Member Functions

 vtkDICOMFile (const char *filename, Mode mode)
 Construct the file object. More...
 
 ~vtkDICOMFile ()
 Destruct the object and close the file.
 
void Close ()
 Close a file.
 
size_t Read (unsigned char *data, size_t size)
 Read data from the file. More...
 
size_t Write (const unsigned char *data, size_t size)
 Write data to a file. More...
 
bool SetPosition (Size offset)
 Go to a specific location in the file. More...
 
Size GetSize ()
 Check the size of the file, returns ULLONG_MAX on error.
 
bool EndOfFile ()
 Check for the end-of-file indicator.
 
int GetError ()
 Return an error indicator (zero if no error).
 

Static Public Member Functions

static int Access (const char *filename, Mode mode)
 Test the specified file for accessibility (static method). More...
 
static int Remove (const char *filename)
 Delete the specified file (static method). More...
 
static bool SameFile (const char *file1, const char *file2)
 Check if two files are the same. More...
 

Detailed Description

A class that provides basic input/output operations.

The purpose of this class is to centralize all of the I/O operations. It uses system-level I/O calls so that it can eventually be used not only on files, but on sockets as well.

Constructor & Destructor Documentation

◆ vtkDICOMFile()

vtkDICOMFile::vtkDICOMFile ( const char *  filename,
Mode  mode 
)

Construct the file object.

The Mode can be "In" or "Out" (read or write).

Member Function Documentation

◆ Access()

static int vtkDICOMFile::Access ( const char *  filename,
Mode  mode 
)
static

Test the specified file for accessibility (static method).

The mode should be "In" or "Out" to indicate how you intend to use the file. The return value will be zero (for an ordinary file) or one of the codes returned by GetError.

◆ Read()

size_t vtkDICOMFile::Read ( unsigned char *  data,
size_t  size 
)

Read data from the file.

The number of bytes read will be returned. A return value of zero indicates an error.

◆ Remove()

static int vtkDICOMFile::Remove ( const char *  filename)
static

Delete the specified file (static method).

The return value is zero if successful, otherwise an error code is returned. This can be called on a file that is still open, in which case the file will be deleted when closed.

◆ SameFile()

static bool vtkDICOMFile::SameFile ( const char *  file1,
const char *  file2 
)
static

Check if two files are the same.

This does not check that the filenames are the same. Instead, it checks to see if the two filenames point to the same actual disk file. If either file does not exist or is otherwise not accessible, then it returns false.

◆ SetPosition()

bool vtkDICOMFile::SetPosition ( Size  offset)

Go to a specific location in the file.

The return value is false if an error occurred.

◆ Write()

size_t vtkDICOMFile::Write ( const unsigned char *  data,
size_t  size 
)

Write data to a file.

The number of bytes written will be returned. If it is less than the size requested, an error occurred.


The documentation for this class was generated from the following file: