本文整理汇总了C++中path::native方法的典型用法代码示例。如果您正苦于以下问题:C++ path::native方法的具体用法?C++ path::native怎么用?C++ path::native使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::native方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
path operator/( path const & p, path const & rel_path )
{
if ( p.empty() ) return rel_path;
if ( rel_path.empty() ) return p;
path::string_type new_path_name = p.native(), rel_path_name = rel_path.native();
if ( !IS_DIR_SEPARATORW( new_path_name.back() ) ) {
new_path_name += ( IS_DIR_SEPARATORW( rel_path_name.front() ) ? L"" : L"\\" ) + rel_path_name;
} else {
int const index = rel_path_name.find_first_not_of( L"\\." );
new_path_name += rel_path_name.substr( index, path::string_type::npos );
}
return path{ new_path_name };
}
示例2: __equivalent
bool __equivalent(const path& p1, const path& p2, std::error_code *ec)
{
std::error_code ec1, ec2;
struct ::stat st1 = {};
struct ::stat st2 = {};
auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
if ((!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))) {
set_or_throw(make_error_code(errc::not_supported), ec,
"equivalent", p1, p2);
return false;
}
if (ec) ec->clear();
return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
}
示例3: Load
void CDynamicLibrary::Load(const path& path) const {
#if UCFG_USE_POSIX
m_hModule = ::dlopen(String(path), 0);
DlCheck(m_hModule == 0);
#else
Win32Check((m_hModule = ::LoadLibrary(String(path.native()))) != 0);
#endif
}
示例4: invalid_argument
std::unique_ptr<std::ifstream> read(const path& path)
{
if (!File::exists(path) || !File::is_regular_file(path)) {
throw std::invalid_argument("File "+path.native()+" not found");
}
return std::unique_ptr<std::ifstream>(new ::boost::filesystem::ifstream(path));
}
示例5: SourceException
Source::Source(Language *sourceLanguage, const path &sourceFilePath) throw(SourceException)
{
//variables
ifstream sourceFile;
FileBuffer *sourceBuffer = nullptr;
size_t sourceFileSize = 0;
//vérification de l'existence du fichier
if (!exists(sourceFilePath))
{
throw SourceException(tr("Le fichier source \"%0\" n'existe pas.", sourceFilePath.native()));
}
//taille du fichier
sourceFileSize = file_size(sourceFilePath);
//ouverture du fichier
sourceFile.open(sourceFilePath.c_str(), ios::in);
if (sourceFile.is_open())
{
//allocation d'un buffer
sourceBuffer = new FileBuffer(sourceFileSize);
//récupération des données dans le fichier source
sourceFile.read(sourceBuffer->getBufferPtr(), sourceBuffer->getBufferSize());
if (sourceFile.bad())
{
throw SourceException(tr("La lecture du fichier source \"%0\" a échoué.", sourceFilePath.native()));
}
//fermeture du fichier
sourceFile.close();
//parsage des données
_sourceParser.parseSource(sourceFilePath.native(), sourceBuffer, sourceLanguage);
//déallocation du buffer
delete sourceBuffer;
}
else
{
//traitement des erreurs
throw SourceException(tr("La lecture du fichier source \"%0\" a échoué.", sourceFilePath.native()));
}
}
示例6: __equivalent
bool __equivalent(const path& p1, const path& p2, std::error_code *ec)
{
auto make_unsupported_error = [&]() {
set_or_throw(make_error_code(errc::not_supported), ec,
"equivalent", p1, p2);
return false;
};
std::error_code ec1, ec2;
struct ::stat st1 = {};
struct ::stat st2 = {};
auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
if (!exists(s1))
return make_unsupported_error();
auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
if (!exists(s2))
return make_unsupported_error();
if (ec) ec->clear();
return detail::stat_equivalent(st1, st2);
}
示例7: prepend
void prepend(path fname, std::vector<uint8_t> const& prepend_data)
{
using namespace boost::iostreams;
auto size = file_size(fname);
auto resized = size + prepend_data.size();
resize_file(fname, resized);
mapped_file mf(fname.native().c_str());
std::rotate(mf.data(), mf.data() + size, mf.data() + resized);
std::copy(prepend_data.begin(), prepend_data.end(), mf.data());
}
示例8: copy_file_transact
void copy_file_transact(const path& from, const path& to)
{
path t = to.native() + ".deleteme";
SCOPE_FAIL{
cout << "Scope Fail" << endl;
::remove(t.c_str());
};
copy_file(from, t);
rename(t, to);
throw 1;
}
示例9: LoadFileAsString
std::string LoadFileAsString(const path &relpath)
{
const path abspath = GetResourceAbspath(relpath);
std::ifstream input;
input.open(abspath.native());
if (!input.is_open())
{
throw std::runtime_error("Cannot open for reading: " + abspath.generic_string());
}
std::string text;
text.reserve(FILE_RESERVE_SIZE);
input.exceptions(std::ios::badbit);
std::string line;
while (std::getline(input, line))
{
text.append(line);
text.append("\n");
}
return text;
}
示例10: compare
int path::compare(const path& p) const noexcept
{
return native() < p.native();
}