Lines Matching refs:FilePath

101 FilePath FilePath::GetCurrentDir() {
109 return FilePath(kCurrentDirectoryString);
112 return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
120 return FilePath(result == nullptr ? kCurrentDirectoryString : cwd);
122 return FilePath(result == nullptr ? "" : cwd);
126 // Returns a copy of the FilePath with the case-insensitive extension removed.
127 // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
128 // FilePath("dir/file"). If a case-insensitive extension is not
129 // found, returns a copy of the original FilePath.
130 FilePath FilePath::RemoveExtension(const char* extension) const {
133 return FilePath(
140 // the FilePath. On Windows, for example, both '/' and '\' are valid path
142 const char* FilePath::FindLastPathSeparator() const {
155 size_t FilePath::CalculateRootLength() const {
193 // Returns a copy of the FilePath with the directory part removed.
194 // Example: FilePath("path/to/file").RemoveDirectoryName() returns
195 // FilePath("file"). If there is no directory part ("just_a_file"), it returns
196 // the FilePath unmodified. If there is no file part ("just_a_dir/") it
197 // returns an empty FilePath ("").
199 FilePath FilePath::RemoveDirectoryName() const {
201 return last_sep ? FilePath(last_sep + 1) : *this;
205 // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
206 // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
207 // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
208 // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
210 FilePath FilePath::RemoveFileName() const {
218 return FilePath(dir);
227 FilePath FilePath::MakeFileName(const FilePath& directory,
228 const FilePath& base_name, int number,
237 return ConcatPaths(directory, FilePath(file));
242 FilePath FilePath::ConcatPaths(const FilePath& directory,
243 const FilePath& relative_path) {
245 const FilePath dir(directory.RemoveTrailingPathSeparator());
246 return FilePath(dir.string() + kPathSeparator + relative_path.string());
251 bool FilePath::FileOrDirectoryExists() const {
265 bool FilePath::DirectoryExists() const {
270 const FilePath& path(IsRootDirectory() ? *this
273 const FilePath& path(*this);
295 bool FilePath::IsRootDirectory() const {
302 bool FilePath::IsAbsolutePath() const { return CalculateRootLength() > 0; }
312 FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
313 const FilePath& base_name,
315 FilePath full_pathname;
323 // Returns true if FilePath ends with a path separator, which indicates that
326 bool FilePath::IsDirectory() const {
334 bool FilePath::CreateDirectoriesRecursively() const {
343 const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
351 bool FilePath::CreateFolder() const {
353 FilePath removed_sep(this->RemoveTrailingPathSeparator());
377 FilePath FilePath::RemoveTrailingPathSeparator() const {
378 return IsDirectory() ? FilePath(pathname_.substr(0, pathname_.length() - 1))
386 void FilePath::Normalize() {