Page MenuHomec4science

filesystem.hpp
No OneTemporary

File Metadata

Created
Fri, May 17, 02:18

filesystem.hpp

/* =============================================================================
Copyright (c) 2014 - 2016
F. Georget <fabieng@princeton.edu> Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
============================================================================= */
#ifndef SPECMICP_UTILS_FILESYSTEM
#define SPECMICP_UTILS_FILESYSTEM
#include "macros.hpp"
#include <string>
#include <vector>
namespace specmicp {
namespace utils {
//! \brief Check that the directory exist
bool SPECMICP_DLL_PUBLIC is_directory(const std::string& path);
//! \brief Check that the directory exist
bool SPECMICP_DLL_PUBLIC is_file(const std::string& path);
//! \brief Return the current directory
std::string SPECMICP_DLL_PUBLIC get_current_directory();
//! \brief Complete a path
std::string SPECMICP_DLL_PUBLIC complete_path(
const std::string& dir,
const std::string& file
);
//! \brief Return an absolute path from a relative one
//!
//! If an error is detected then the return string will be empty,
//! and error will contain a message about the error
std::string SPECMICP_DLL_PUBLIC relative_to_absolute(
const std::string& rel_path,
std::string& error
);
//! \brief Return the complete path to a file from a set of directories
std::string SPECMICP_DLL_PUBLIC find_path(
std::string filename,
const std::vector<std::string>& directories
);
//! \brief Return true if the environment variable is defined
bool SPECMICP_DLL_PUBLIC has_env(
const std::string& env_var
);
//! \brief Return an environment variable
std::string SPECMICP_DLL_PUBLIC get_env(
const std::string& env_var
);
} // end namespace utils
} // end namespace specmicp
#endif // SPECMICP_UTILS_FILESYSTEM

Event Timeline