+ std::string toSafeFilesystemEncoding(os::file_access how = os::EXISTING) const;
+
+ /// returns true if the file exists
+ bool exists() const;
+ /// refreshes the file info
+ void refresh() const;
+ /// \return true if this object points to a symbolic link.
+ bool isSymLink() const;
+ /// \return true if the file is empty.
+ bool isFileEmpty() const;
+ /// returns time of last write access
+ std::time_t lastModified() const;
+ /// generates a checksum of a file
+ virtual unsigned long checksum() const;
+ /// return true when file is readable but not writable
+ bool isReadOnly() const;
+ /// return true when it names a directory
+ bool isDirectory() const;
+ /// return true when directory is readable
+ bool isReadableDirectory() const;
+ /// return true when it is a file and readable
+ virtual bool isReadableFile() const;
+ /// return true when file/directory is writable
+ bool isWritable() const;
+ /// return true when file/directory is writable (write test file)
+ bool isDirWritable() const;
+ /// \return list other files in the directory having optional extension 'ext'.
+ FileNameList dirList(std::string const & ext) const;
+
+ /// copy a file
+ /// \return true when file/directory is writable (write test file)
+ /// \warning This methods has different semantics when system level
+ /// copy command, it will overwrite the \c target file if it exists,
+ /// If \p keepsymlink is true, the copy will be written to the symlink
+ /// target. Otherwise, the symlink will be destroyed.
+ bool copyTo(FileName const & target, bool keepsymlink = false) const;
+
+ /// remove pointed file.
+ /// \return true on success.
+ bool removeFile() const;
+
+ /// rename pointed file.
+ /// \return false if the operation fails or if the \param target file
+ /// already exists.
+ /// \return true on success.
+ bool renameTo(FileName const & target) const;
+
+ /// move pointed file to \param target.
+ /// If \p target exists it will be overwritten (if it is a symlink,
+ /// the symlink will be destroyed).
+ /// \return true on success.
+ bool moveTo(FileName const & target) const;
+ bool link(FileName const & name) const;
+
+ /// change mode of pointed file.
+ /// This methods does nothing and return true on platforms that does not
+ /// support this.
+ /// \return true on success.
+ bool changePermission(unsigned long int mode) const;
+
+ /// remove pointed directory and all contents.
+ /// \return true on success.
+ bool destroyDirectory() const;
+ /// Creates pointed directory.
+ /// \return true on success.
+ bool createDirectory(int permissions) const;
+ /// Creates pointed path.
+ /// \return true on success.
+ bool createPath() const;
+
+ /// Get the contents of a file as a huge docstring.
+ /// \param encoding defines the encoding of the file contents.
+ /// Only four encodings are supported:
+ /// "UTF-8", "ascii", "latin1" and "local8bit" which uses the
+ /// current system locale.
+ docstring fileContents(std::string const & encoding) const;
+
+ /// Change extension.
+ /**
+ * If oldname does not have an extension, it is appended.
+ * If the extension is empty, any extension is removed from the name.
+ */
+ void changeExtension(std::string const & extension);
+
+ static FileName fromFilesystemEncoding(std::string const & 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;