File: gdcmFilename.h

package info (click to toggle)
gdcm 2.4.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 32,868 kB
  • sloc: cpp: 188,481; ansic: 124,526; xml: 41,799; sh: 7,162; python: 3,667; cs: 2,128; java: 1,344; lex: 1,290; tcl: 677; php: 128; makefile: 116
file content (74 lines) | stat: -rw-r--r-- 2,318 bytes parent folder | download | duplicates (2)
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
/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html 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 GDCMFILENAME_H
#define GDCMFILENAME_H

#include "gdcmTypes.h"

#include <string>

namespace gdcm
{
/**
 * \brief Class to manipulate file name's
 * \note OS independant representation of a filename (to query path, name and extension from a filename)
 */
class GDCM_EXPORT Filename
{
public:
  Filename(const char* filename = ""):FileName(filename ? filename : ""),Path(),Conversion() {}

  /// Return the full filename
  const char *GetFileName() const { return FileName.c_str(); }
  /// Return only the path component of a filename
  const char *GetPath();
  /// return only the name part of a filename
  const char *GetName();
  /// return only the extension part of a filename
  const char *GetExtension();
  /// Convert backslash (windows style) to UNIX style slash.
  const char *ToUnixSlashes();
  /// Convert foward slash (UNIX style) to windows style slash.
  const char *ToWindowsSlashes();

  /// Join two paths
  /// NOT THREAD SAFE
  static const char *Join(const char *path, const char *filename);

  /// return whether the filename is empty
  bool IsEmpty() const { return FileName.empty(); }

  /// Simple operator to allow
  /// Filename myfilename( "..." );
  /// const char * s = myfilename;
  operator const char * () const { return GetFileName(); }

  // FIXME: I don't like this function
  // It hides the realpath call (maybe usefull)
  // and it forces file to exist on the disk whereas Filename
  // should be independant from file existence.
  bool IsIdentical(Filename const &fn) const;

  /// Does the filename ends with a particular string ?
  bool EndWith(const char ending[]) const;

private:
  std::string FileName;
  std::string Path;
  std::string Conversion;
};

} // end namespace gdcm

#endif //GDCMFILENAME_H