Path.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2017 Imperial College London
5  * Copyright 2013-2017 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_Path_H
21 #define MIRTK_Path_H
22 
23 #include "mirtk/CommonExport.h"
24 
25 #include "mirtk/String.h"
26 
27 
28 namespace mirtk {
29 
30 // =============================================================================
31 // Global constants
32 // =============================================================================
33 
34 /// Path separating character
35 MIRTK_Common_EXPORT extern const char PATHSEP;
36 
37 // =============================================================================
38 // Split file path
39 // =============================================================================
40 
41 /// Enumeration of file path extension retrival modes
43 {
44  EXT_Default, ///< Default extension mode
45  EXT_None, ///< No part of the file is considered to be an extension
46  EXT_Last, ///< Last file extension only
47  EXT_LastWithGz, ///< Last file extension possibly plus ".gz"
48  EXT_LastWithoutGz, ///< Last file extension with possibly ".gz" removed first
49  EXT_All ///< All file extensions, i.e., everything after first dot (besides leading dot of hidden files on Unix)
50 };
51 
52 /// Get file name extension in lower case incl. leading dot ('.')
53 string Extension(const char *, ExtensionMode = EXT_Default);
54 
55 /// Get file name extension in lower case incl. leading dot ('.')
56 string Extension(const string &, ExtensionMode = EXT_Default);
57 
58 /// Get directory part of file path
59 string Directory(const char *);
60 
61 /// Get directory part of file path
62 string Directory(const string &);
63 
64 /// Get file name of file path incl. file extension
65 string BaseName(const char *);
66 
67 /// Get file name of file path incl. file extension
68 string BaseName(const string &);
69 
70 /// Get file name of file path excl. file extension
71 string FileName(const char *, ExtensionMode = EXT_Default);
72 
73 /// Get file name of file path excl. file extension
74 string FileName(const string &, ExtensionMode = EXT_Default);
75 
76 /// Get file path excl. file extension
77 string FilePrefix(const char *, ExtensionMode = EXT_Default);
78 
79 /// Get file path excl. file extension
80 string FilePrefix(const string &, ExtensionMode = EXT_Default);
81 
82 
83 } // namespace mirtk
84 
85 #endif // MIRTK_Path_H
string FileName(const char *, ExtensionMode=EXT_Default)
Get file name of file path excl. file extension.
Last file extension with possibly ".gz" removed first.
Definition: Path.h:48
Last file extension only.
Definition: Path.h:46
string BaseName(const char *)
Get file name of file path incl. file extension.
string Directory(const char *)
Get directory part of file path.
ExtensionMode
Enumeration of file path extension retrival modes.
Definition: Path.h:42
Last file extension possibly plus ".gz".
Definition: Path.h:47
string FilePrefix(const char *, ExtensionMode=EXT_Default)
Get file path excl. file extension.
Definition: IOConfig.h:41
All file extensions, i.e., everything after first dot (besides leading dot of hidden files on Unix) ...
Definition: Path.h:49
MIRTK_Common_EXPORT const char PATHSEP
Path separating character.
string Extension(const char *, ExtensionMode=EXT_Default)
Get file name extension in lower case incl. leading dot (&#39;.&#39;)
No part of the file is considered to be an extension.
Definition: Path.h:45
Default extension mode.
Definition: Path.h:44