- /// (securely) create a temporary file in the given dir with the given mask
- /// \p mask must be in filesystem encoding
- static FileName tempName(FileName const & dir = FileName(),
- std::string const & mask = std::string());
-protected:
- /// The absolute file name.
- /// The encoding is currently unspecified, anything else than ASCII
- /// may or may not work.
- std::string name_;
+
+ /// get the current working directory
+ static FileName getcwd();
+
+ static FileName tempPath();
+
+ /// filename without path
+ std::string onlyFileName() const;
+ /// filename without path and without extension
+ std::string onlyFileNameWithoutExt() const;
+ /// only extension after the last dot.
+ std::string extension() const;
+ /** checks if the file has the given extension
+ on Windows and Mac it compares case insensitive */
+ bool hasExtension(const std::string & ext);
+ /// path without file name
+ FileName onlyPath() const;
+ /// path of parent directory
+ /// returns empty path for root directory
+ FileName parentPath() const;
+ /// used for display in the Gui
+ docstring displayName(int threshold = 1000) const;
+
+ /// change to a directory, return success
+ bool chdir() const;
+
+ /// \param buffer_path if empty, uses `pwd`
+ docstring const relPath(std::string const & path) const;
+
+ docstring const absoluteFilePath() const;
+
+private:
+ friend bool equivalent(FileName const &, FileName const &);
+ /// Set for tracking of already visited file names.
+ /// Uses operator==() (which may be case insensitive), and not
+ /// equvalent(), so that symlinks are not resolved.
+ typedef std::set<FileName> FileNameSet;
+ /// Helper for public copyTo() to find circular symlink chains
+ bool copyTo(FileName const &, bool, FileNameSet &) const;
+ ///
+ struct Private;
+ Private * const d;