/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2011,2012, 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
*
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \inlibraryapi
+ * \ingroup module_utility
*/
#ifndef GMX_UTILITY_PATH_H
#define GMX_UTILITY_PATH_H
#include <string>
#include <utility>
+#include <vector>
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
{