2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef WRTDEVICEAPIS_FILESYSTEM_IPATH_H_
17 #define WRTDEVICEAPIS_FILESYSTEM_IPATH_H_
20 #include <dpl/shared_ptr.h>
22 namespace WrtDeviceApis {
23 namespace Filesystem {
26 typedef DPL::SharedPtr<IPath> IPathPtr;
31 typedef char SeparatorType;
35 * Creates path object from specified string.
36 * @param str Path string.
38 * @throw InvalidArgumentException If supplied string is not a valid path.
39 * @throw PlatformException If error in platform occurs.
40 * @remarks Ownership passed to the caller.
42 static IPathPtr create(const std::string& str);
45 * Gets separator used by current platform.
46 * @return Path separator.
48 static SeparatorType getSeparator();
57 virtual std::string getFullPath() const = 0;
60 * Gets base path (full path w/o name).
63 virtual std::string getPath() const = 0;
66 * Gets the last part of path.
67 * @return Path's name.
68 * @return Last part is typically name of a directory or file.
70 virtual std::string getName() const = 0;
73 * Appends path specified as string to current path.
74 * @param path Path to append.
75 * @return Current path object.
77 virtual IPathPtr append(const std::string& path) = 0;
80 * Appends path specified as path object to current path.
81 * @param path Path to append.
82 * @return Current path object.
84 virtual IPathPtr append(const IPathPtr& path) = 0;
87 * Checks if path is abolute.
88 * @return True if absolute, false if relative.
90 virtual bool isAbsolute() const = 0;
94 * @return Independent copy.
96 virtual IPathPtr clone() const = 0;
99 inline const IPathPtr operator+(const IPath& lhs,
102 return IPath::create(lhs.getFullPath())->append(rhs.getFullPath());
105 inline const IPathPtr operator+(const IPath& lhs,
106 const std::string& rhs)
108 return IPath::create(lhs.getFullPath())->append(rhs);
111 inline const IPathPtr operator+(const std::string& lhs,
114 return IPath::create(lhs)->append(rhs.getFullPath());
117 inline bool operator==(const IPath& lhs, const IPath& rhs)
119 return (lhs.getFullPath() == rhs.getFullPath());
122 inline bool operator==(const IPath& lhs, const std::string& rhs)
124 return (lhs.getFullPath() == rhs);
127 inline bool operator==(const std::string& lhs, const IPath& rhs)
129 return (lhs == rhs.getFullPath());
132 inline bool operator!=(const IPath& lhs, const IPath& rhs)
134 return (lhs.getFullPath() != rhs.getFullPath());
137 inline bool operator!=(const IPath& lhs, const std::string& rhs)
139 return (lhs.getFullPath() != rhs);
142 inline bool operator!=(const std::string& lhs, const IPath& rhs)
144 return (lhs != rhs.getFullPath());
150 #endif // WRTDEVICEAPIS_FILESYSTEM_IPATH_H_