FreeNOS
FileSystemPath.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBFS_FILESYSTEMPATH_H
19 #define __LIB_LIBFS_FILESYSTEMPATH_H
20 
21 #include <List.h>
22 #include <ListIterator.h>
23 #include <Types.h>
24 #include <String.h>
25 
38 {
39  private:
40 
42  static const char DefaultSeparator = '/';
43 
44  public:
45 
47  static const Size MaximumLength = 64u;
48 
49  public:
50 
57  FileSystemPath(const char *path,
58  const char separator = DefaultSeparator);
59 
65  const String & parent() const;
66 
72  const String & base() const;
73 
79  const String & full() const;
80 
86  const List<String> & split() const;
87 
93  Size length() const;
94 
95  private:
96 
98  const char m_separator;
99 
101  const String m_full;
102 
105 
107  const String m_base;
108 
111 };
112 
118 #endif /* __LIB_LIBFS_FILESYSTEMPATH_H */
FileSystemPath::m_parent
String m_parent
Full path to our parent.
Definition: FileSystemPath.h:110
FileSystemPath
Simple filesystem path parser.
Definition: FileSystemPath.h:37
Types.h
String
Abstraction of strings.
Definition: String.h:41
FileSystemPath::full
const String & full() const
Get the full path as a String.
Definition: FileSystemPath.cpp:58
FileSystemPath::DefaultSeparator
static const char DefaultSeparator
The default path separator character.
Definition: FileSystemPath.h:42
FileSystemPath::m_full
const String m_full
Full input path.
Definition: FileSystemPath.h:101
FileSystemPath::base
const String & base() const
The name of the last element in the path.
Definition: FileSystemPath.cpp:53
FileSystemPath::MaximumLength
static const Size MaximumLength
Maximum length of a filesystem path in bytes.
Definition: FileSystemPath.h:47
FileSystemPath::split
const List< String > & split() const
Returns a List of separate path elements.
Definition: FileSystemPath.cpp:63
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
FileSystemPath::m_base
const String m_base
Last element in the full path.
Definition: FileSystemPath.h:107
FileSystemPath::m_separator
const char m_separator
Separator character.
Definition: FileSystemPath.h:98
FileSystemPath::length
Size length() const
Get Length of our full path.
Definition: FileSystemPath.cpp:68
ListIterator.h
FileSystemPath::parent
const String & parent() const
Retrieve the full path of our parent.
Definition: FileSystemPath.cpp:48
FileSystemPath::m_path
const List< String > m_path
The path split in pieces by the separator.
Definition: FileSystemPath.h:104
String.h
List< String >
List.h
FileSystemPath::FileSystemPath
FileSystemPath(const char *path, const char separator=DefaultSeparator)
Constructor using char pointer.
Definition: FileSystemPath.cpp:22