Lines Matching +full:- +full:filepath
1 /*-------------------------------------------------------------------------
3 * -----------------------------
11 * http://www.apache.org/licenses/LICENSE-2.0
22 *//*--------------------------------------------------------------------*/
45 const std::string FilePath::separator = "\\";
47 const std::string FilePath::separator = "/";
50 FilePath::FilePath(const std::vector<std::string> &components) in FilePath() function in de::FilePath
54 if (!m_path.empty() && !isSeparator(m_path[m_path.size() - 1])) in FilePath()
60 void FilePath::split(std::vector<std::string> &components) const in split()
78 if (pos - curCompStart > 0) in split()
79 components.push_back(m_path.substr(curCompStart, pos - curCompStart)); in split()
85 if (pos - curCompStart > 0) in split()
86 components.push_back(m_path.substr(curCompStart, pos - curCompStart)); in split()
89 FilePath FilePath::join(const std::vector<std::string> &components) in join()
91 return FilePath(components); in join()
94 FilePath &FilePath::normalize(void) in normalize()
106 for (int ndx = (int)components.size() - 1; ndx >= 0; ndx--) in normalize()
114 numUp -= 1; // Skip part in normalize()
123 while (numUp--) in normalize()
134 FilePath FilePath::normalize(const FilePath &path) in normalize()
136 return FilePath(path).normalize(); in normalize()
139 std::string FilePath::getBaseName(void) const in getBaseName()
143 return !components.empty() ? components[components.size() - 1] : std::string(""); in getBaseName()
146 std::string FilePath::getDirName(void) const in getDirName()
153 return FilePath(components).getPath(); in getDirName()
161 std::string FilePath::getFileExtension(void) const in getFileExtension()
171 bool FilePath::exists(void) const in exists()
173 FilePath normPath = FilePath::normalize(*this); in exists()
179 FilePath::Type FilePath::getType(void) const in getType()
181 FilePath normPath = FilePath::normalize(*this); in getType()
197 bool FilePath::beginsWithDrive(void) const in beginsWithDrive()
209 bool FilePath::isAbsolutePath(void) const in isAbsolutePath()
216 DE_TEST_ASSERT(!FilePath(".").isAbsolutePath()); in FilePath_selfTest()
217 DE_TEST_ASSERT(!FilePath("..\\foo").isAbsolutePath()); in FilePath_selfTest()
218 DE_TEST_ASSERT(!FilePath("foo").isAbsolutePath()); in FilePath_selfTest()
219 DE_TEST_ASSERT(FilePath("\\foo/bar").isAbsolutePath()); in FilePath_selfTest()
220 DE_TEST_ASSERT(FilePath("/foo").isAbsolutePath()); in FilePath_selfTest()
221 DE_TEST_ASSERT(FilePath("\\").isAbsolutePath()); in FilePath_selfTest()
222 DE_TEST_ASSERT(FilePath("\\\\net\\loc").isAbsolutePath()); in FilePath_selfTest()
223 DE_TEST_ASSERT(FilePath("C:\\file.txt").isAbsolutePath()); in FilePath_selfTest()
224 DE_TEST_ASSERT(FilePath("c:/file.txt").isAbsolutePath()); in FilePath_selfTest()
226 DE_TEST_ASSERT(string(".") == FilePath(".//.").normalize().getPath()); in FilePath_selfTest()
227 DE_TEST_ASSERT(string(".") == FilePath(".").normalize().getPath()); in FilePath_selfTest()
228 DE_TEST_ASSERT((string("..") + FilePath::separator + "test") == in FilePath_selfTest()
229 FilePath("foo/../bar/../../test").normalize().getPath()); in FilePath_selfTest()
230 DE_TEST_ASSERT((FilePath::separator + "foo" + FilePath::separator + "foo.txt") == in FilePath_selfTest()
231 FilePath("/foo\\bar/..\\dir\\..\\foo.txt").normalize().getPath()); in FilePath_selfTest()
232 DE_TEST_ASSERT((string("c:") + FilePath::separator + "foo" + FilePath::separator + "foo.txt") == in FilePath_selfTest()
233 FilePath("c:/foo\\bar/..\\dir\\..\\foo.txt").normalize().getPath()); in FilePath_selfTest()
234 …DE_TEST_ASSERT((FilePath::separator + FilePath::separator + "foo" + FilePath::separator + "foo.txt… in FilePath_selfTest()
235 FilePath("\\\\foo\\bar/..\\dir\\..\\foo.txt").normalize().getPath()); in FilePath_selfTest()
237 DE_TEST_ASSERT(FilePath("foo/bar").getBaseName() == "bar"); in FilePath_selfTest()
238 DE_TEST_ASSERT(FilePath("foo/bar/").getBaseName() == "bar"); in FilePath_selfTest()
239 DE_TEST_ASSERT(FilePath("foo\\bar").getBaseName() == "bar"); in FilePath_selfTest()
240 DE_TEST_ASSERT(FilePath("foo\\bar\\").getBaseName() == "bar"); in FilePath_selfTest()
241 DE_TEST_ASSERT(FilePath("foo/bar").getDirName() == "foo"); in FilePath_selfTest()
242 DE_TEST_ASSERT(FilePath("foo/bar/").getDirName() == "foo"); in FilePath_selfTest()
243 DE_TEST_ASSERT(FilePath("foo\\bar").getDirName() == "foo"); in FilePath_selfTest()
244 DE_TEST_ASSERT(FilePath("foo\\bar\\").getDirName() == "foo"); in FilePath_selfTest()
245 …DE_TEST_ASSERT(FilePath("/foo/bar/baz").getDirName() == FilePath::separator + "foo" + FilePath::se… in FilePath_selfTest()
264 FilePath dirPath = FilePath::normalize(path); in createDirectory()
265 FilePath parentPath(dirPath.getDirName()); in createDirectory()
271 else if (parentPath.getType() != FilePath::TYPE_DIRECTORY) in createDirectory()
280 FilePath curPath(path); in createDirectoryAndParents()
291 curPath = FilePath(parent); in createDirectoryAndParents()
297 createDirectory(parentIter->c_str()); in createDirectoryAndParents()