2015-09-15 18:49:18 -04:00
|
|
|
/*
|
2016-01-14 16:50:22 -05:00
|
|
|
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
2015-09-15 18:49:18 -04:00
|
|
|
|
2016-01-14 16:50:22 -05:00
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
2015-09-15 18:49:18 -04:00
|
|
|
|
2016-01-14 16:50:22 -05:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2015-09-15 18:49:18 -04:00
|
|
|
*/
|
|
|
|
|
2017-06-30 11:15:20 -04:00
|
|
|
#pragma once
|
2015-09-15 18:49:18 -04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace fs
|
|
|
|
{
|
|
|
|
namespace path
|
|
|
|
{
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string dirname(const char *path);
|
|
|
|
std::string dirname(const std::string &path);
|
2015-09-15 18:49:18 -04:00
|
|
|
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string basename(const std::string &path);
|
2015-09-15 18:49:18 -04:00
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
static
|
2015-09-15 18:49:18 -04:00
|
|
|
inline
|
|
|
|
void
|
2020-08-16 18:22:25 -04:00
|
|
|
append(std::string &base_,
|
|
|
|
const char *suffix_)
|
2015-09-15 18:49:18 -04:00
|
|
|
{
|
2020-08-16 18:22:25 -04:00
|
|
|
base_ += suffix_;
|
2015-09-15 18:49:18 -04:00
|
|
|
}
|
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
static
|
2017-06-24 17:03:41 -04:00
|
|
|
inline
|
|
|
|
void
|
2020-08-16 18:22:25 -04:00
|
|
|
append(std::string &base_,
|
|
|
|
const std::string &suffix_)
|
2017-06-24 17:03:41 -04:00
|
|
|
{
|
2020-08-16 18:22:25 -04:00
|
|
|
base_ += suffix_;
|
2017-06-24 17:03:41 -04:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:31:50 -04:00
|
|
|
static
|
|
|
|
inline
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string
|
2020-07-16 15:31:50 -04:00
|
|
|
make(const char *base_,
|
|
|
|
const char *suffix_)
|
|
|
|
{
|
|
|
|
char back;
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string path(base_);
|
2020-07-16 15:31:50 -04:00
|
|
|
|
|
|
|
back = *path.rbegin();
|
|
|
|
if((back != '/') && (suffix_[0] != '/'))
|
|
|
|
path.push_back('/');
|
|
|
|
path += suffix_;
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
static
|
2019-01-09 00:01:52 -05:00
|
|
|
inline
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string
|
|
|
|
make(const std::string &base_,
|
|
|
|
const char *suffix_)
|
2017-06-24 17:03:41 -04:00
|
|
|
{
|
2019-01-25 07:03:46 -05:00
|
|
|
return (base_ + suffix_);
|
2017-06-24 17:03:41 -04:00
|
|
|
}
|
2018-10-13 23:48:30 -04:00
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
static
|
2018-10-13 23:48:30 -04:00
|
|
|
inline
|
2020-08-16 18:22:25 -04:00
|
|
|
std::string
|
|
|
|
make(const std::string &base_,
|
|
|
|
const std::string &suffix_)
|
2019-01-25 07:03:46 -05:00
|
|
|
{
|
|
|
|
return (base_ + suffix_);
|
|
|
|
}
|
2015-09-15 18:49:18 -04:00
|
|
|
}
|
|
|
|
};
|