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 {
27 typedef DPL::SharedPtr<IPath> IPathPtr;
32 typedef char SeparatorType;
36 * Creates path object from specified string.
37 * @param str Path string.
39 * @throw InvalidArgumentException If supplied string is not a valid path.
40 * @throw PlatformException If error in platform occurs.
41 * @remarks Ownership passed to the caller.
43 static IPathPtr create(const std::string& str);
46 * Gets separator used by current platform.
47 * @return Path separator.
49 static SeparatorType getSeparator();
58 virtual std::string getFullPath() const = 0;
61 * Gets base path (full path w/o name).
64 virtual std::string getPath() const = 0;
67 * Gets the last part of path.
68 * @return Path's name.
69 * @return Last part is typically name of a directory or file.
71 virtual std::string getName() const = 0;
74 * Appends path specified as string to current path.
75 * @param path Path to append.
76 * @return Current path object.
78 virtual IPathPtr append(const std::string& path) = 0;
81 * Appends path specified as path object to current path.
82 * @param path Path to append.
83 * @return Current path object.
85 virtual IPathPtr append(const IPathPtr& path) = 0;
88 * Checks if path is abolute.
89 * @return True if absolute, false if relative.
91 virtual bool isAbsolute() const = 0;
95 * @return Independent copy.
97 virtual IPathPtr clone() const = 0;
100 inline const IPathPtr operator+(const IPath& lhs,
103 return IPath::create(lhs.getFullPath())->append(rhs.getFullPath());
106 inline const IPathPtr operator+(const IPath& lhs,
107 const std::string& rhs)
109 return IPath::create(lhs.getFullPath())->append(rhs);
112 inline const IPathPtr operator+(const std::string& lhs,
115 return IPath::create(lhs)->append(rhs.getFullPath());
118 inline bool operator==(const IPath& lhs, const IPath& rhs)
120 return (lhs.getFullPath() == rhs.getFullPath());
123 inline bool operator==(const IPath& lhs, const std::string& rhs)
125 return (lhs.getFullPath() == rhs);
128 inline bool operator==(const std::string& lhs, const IPath& rhs)
130 return (lhs == rhs.getFullPath());
133 inline bool operator!=(const IPath& lhs, const IPath& rhs)
135 return (lhs.getFullPath() != rhs.getFullPath());
138 inline bool operator!=(const IPath& lhs, const std::string& rhs)
140 return (lhs.getFullPath() != rhs);
143 inline bool operator!=(const std::string& lhs, const IPath& rhs)
145 return (lhs != rhs.getFullPath());
152 #endif // WRTDEVICEAPIS_FILESYSTEM_IPATH_H_