Remove gmx::File (except for File::exists())
[alexxy/gromacs.git] / src / gromacs / utility / path.h
index 4b1d2bde43fed5592176d1bc8d19b40c2c2e5738..8dba41e84c0f1947cb21c62b907eb601e4ad911e 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -45,6 +45,7 @@
 
 #include <string>
 #include <utility>
+#include <vector>
 
 namespace gmx
 {
@@ -52,19 +53,57 @@ namespace gmx
 class Path
 {
     public:
+        static bool containsDirectory(const std::string &path);
+        static bool isAbsolute(const char *path);
+        static bool isAbsolute(const std::string &path);
+        static bool isEquivalent(const std::string &path1,
+                                 const std::string &path2);
+
         static std::string join(const std::string &path1,
                                 const std::string &path2);
         static std::string join(const std::string &path1,
                                 const std::string &path2,
                                 const std::string &path3);
-        static std::pair<std::string, std::string>
-        splitToPathAndFilename(const std::string &path);
+        static std::string normalize(const std::string &path);
+        static std::string getParentPath(const std::string &path);
+        static std::string getFilename(const std::string &path);
+        static bool hasExtension(const std::string &path);
+        static std::string stripExtension(const std::string &path);
+
+        static bool exists(const char *path);
+        static bool exists(const std::string &path);
+        static std::string getWorkingDirectory();
+
+        static void splitPathEnvironment(const std::string        &pathEnv,
+                                         std::vector<std::string> *result);
+        static std::vector<std::string> getExecutablePaths();
+
+        static std::string resolveSymlinks(const std::string &path);
 
     private:
         // Disallow instantiation.
         Path();
 };
 
+class File
+{
+    public:
+        /*! \brief
+         * Checks whether a file exists and is a regular file.
+         *
+         * \param[in] filename  Path to the file to check.
+         * \returns   `true` if \p filename exists and is accessible.
+         *
+         * Does not throw.
+         */
+        static bool exists(const char *filename);
+        //! \copydoc exists(const char *)
+        static bool exists(const std::string &filename);
+
+    private:
+        // Disallow instantiation.
+        File();
+};
 
 class Directory
 {