]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.h
add FileName::renameTo() method.
[lyx.git] / src / support / FileName.h
index f53290159f18caf4561df4a66a6a7d8927d7275f..328602bf34e692aaa968e9def85116ff5ceeb767 100644 (file)
 #include "support/strfwd.h"
 
 #include <ctime>
-#include <vector>
 
 
 namespace lyx {
 namespace support {
 
+/// Defined in "FileNameList.h".
+class FileNameList;
+
 /**
  * Class for storing file names.
  * The file name may be empty. If it is not empty it is an absolute path.
@@ -83,6 +85,8 @@ public:
        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)
@@ -94,19 +98,22 @@ public:
        /// \retrun true on success.
        bool removeFile() const;
 
+       /// rename pointed file.
+       /// \retrun true on success.
+       bool renameTo(FileName const & target) const;
+
+
        /// remove directory and all contents, returns true on success
        bool destroyDirectory() const;
        /// Creates directory. Returns true on success
        bool createDirectory(int permissions) const;
 
-       /// Get the contents of a file as a huge std::string
-       std::string fileContents() const;
-       /**
-        * Get a FileName from \p name in the encoding used by the file system.
-        * Only use this for filenames you got directly from the file system,
-        * e.g. from reading a directory.
-        * \p name must have an absolute path.
-        */
+       /// 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.
        /**
@@ -139,12 +146,11 @@ public:
 
        /// change to a directory, return success
        bool chdir() const;
-
-       /// \return list other files in the directory having optional extension 'ext'.
-       std::vector<FileName> dirList(std::string const & ext = empty_string());
        
        /// \param buffer_path if empty, uses `pwd`
        docstring const relPath(std::string const & path) const;
+       
+       docstring const absoluteFilePath() const;
 
 private:
        ///
@@ -230,7 +236,6 @@ private:
 bool operator==(DocFileName const &, DocFileName const &);
 bool operator!=(DocFileName const &, DocFileName const &);
 
-
 } // namespace support
 } // namespace lyx