本文整理汇总了C++中pal::string_t::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ string_t::empty方法的具体用法?C++ string_t::empty怎么用?C++ string_t::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal::string_t
的用法示例。
在下文中一共展示了string_t::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolve_hostpolicy_dir_from_probe_paths
/**
* Given a version and probing paths, find if package layout
* directory containing hostpolicy exists.
*/
bool resolve_hostpolicy_dir_from_probe_paths(const pal::string_t& version, const std::vector<pal::string_t>& probe_realpaths, pal::string_t* candidate)
{
if (probe_realpaths.empty() || version.empty())
{
return false;
}
// Check if the package relative directory containing hostpolicy exists.
for (const auto& probe_path : probe_realpaths)
{
trace::verbose(_X("Considering %s to probe for %s"), probe_path.c_str(), LIBHOSTPOLICY_NAME);
if (to_hostpolicy_package_dir(probe_path, version, candidate))
{
return true;
}
}
// Print detailed message about the file not found in the probe paths.
trace::error(_X("Could not find required library %s in %d probing paths:"),
LIBHOSTPOLICY_NAME, probe_realpaths.size());
for (const auto& path : probe_realpaths)
{
trace::error(_X(" %s"), path.c_str());
}
return false;
}
示例2: get_framework_and_sdk_locations
void get_framework_and_sdk_locations(const pal::string_t& dotnet_dir, std::vector<pal::string_t>* locations)
{
bool multilevel_lookup = multilevel_lookup_enabled();
// Multi-level lookup will look for the most appropriate version in several locations
// by following the priority rank below:
// .exe directory
// Global .NET directories
// If it is not activated, then only .exe directory will be considered
pal::string_t dotnet_dir_temp;
if (!dotnet_dir.empty())
{
// own_dir contains DIR_SEPARATOR appended that we need to remove.
dotnet_dir_temp = dotnet_dir;
remove_trailing_dir_seperator(&dotnet_dir_temp);
locations->push_back(dotnet_dir_temp);
}
std::vector<pal::string_t> global_dirs;
if (multilevel_lookup && pal::get_global_dotnet_dirs(&global_dirs))
{
for (pal::string_t dir : global_dirs)
{
// avoid duplicate paths
if (!pal::are_paths_equal_with_normalized_casing(dir, dotnet_dir_temp))
{
locations->push_back(dir);
}
}
}
}
示例3: to_hostpolicy_package_dir
/**
* Given a directory and a version, find if the package relative
* dir under the given directory contains hostpolicy.dll
*/
bool to_hostpolicy_package_dir(const pal::string_t& dir, const pal::string_t& version, pal::string_t* candidate)
{
assert(!version.empty());
candidate->clear();
// Ensure the relative dir contains platform directory separators.
pal::string_t rel_dir = _STRINGIFY(HOST_POLICY_PKG_REL_DIR);
if (DIR_SEPARATOR != '/')
{
replace_char(&rel_dir, '/', DIR_SEPARATOR);
}
// Construct the path to directory containing hostpolicy.
pal::string_t path = dir;
append_path(&path, _STRINGIFY(HOST_POLICY_PKG_NAME)); // package name
append_path(&path, version.c_str()); // package version
append_path(&path, rel_dir.c_str()); // relative dir containing hostpolicy library
// Check if "path" contains the required library.
if (!library_exists_in_dir(path, LIBHOSTPOLICY_NAME, nullptr))
{
trace::verbose(_X("Did not find %s in directory %s"), LIBHOSTPOLICY_NAME, path.c_str());
return false;
}
// "path" contains the directory containing hostpolicy library.
*candidate = path;
trace::verbose(_X("Found %s in directory %s"), LIBHOSTPOLICY_NAME, path.c_str());
return true;
}
示例4: file_exists
bool pal::file_exists(const pal::string_t& path)
{
if (path.empty())
{
return false;
}
struct stat buffer;
return (::stat(path.c_str(), &buffer) == 0);
}
示例5: starts_with
bool starts_with(const pal::string_t& value, const pal::string_t& prefix, bool match_case)
{
if (prefix.empty())
{
// Cannot start with an empty string.
return false;
}
auto cmp = match_case ? pal::strncmp : pal::strncasecmp;
return (value.size() >= prefix.size()) &&
cmp(value.c_str(), prefix.c_str(), prefix.size()) == 0;
}
示例6: hostpolicy_exists_in_svc
/**
* Given a nuget version, detect if a serviced hostpolicy is available at
* platform servicing location.
*/
bool hostpolicy_exists_in_svc(const pal::string_t& version, pal::string_t* resolved_dir)
{
if (version.empty())
{
return false;
}
pal::string_t svc_dir;
pal::get_default_servicing_directory(&svc_dir);
append_path(&svc_dir, _X("pkgs"));
return to_hostpolicy_package_dir(svc_dir, version, resolved_dir);
}
示例7: get_filename_without_ext
pal::string_t get_filename_without_ext(const pal::string_t& path)
{
if (path.empty())
{
return path;
}
size_t name_pos = path.find_last_of(_X("/\\"));
size_t dot_pos = path.rfind(_X('.'));
size_t start_pos = (name_pos == pal::string_t::npos) ? 0 : (name_pos + 1);
size_t count = (dot_pos == pal::string_t::npos || dot_pos < start_pos) ? pal::string_t::npos : (dot_pos - start_pos);
return path.substr(start_pos, count);
}
示例8: try_stou
bool try_stou(const pal::string_t& str, unsigned* num)
{
if (str.empty())
{
return false;
}
if (index_of_non_numeric(str, 0) != pal::string_t::npos)
{
return false;
}
*num = (unsigned)std::stoul(str);
return true;
}
示例9: try_stou
bool try_stou(const pal::string_t& str, unsigned* num)
{
if (str.empty())
{
return false;
}
if (str.find_first_not_of(_X("0123456789")) != pal::string_t::npos)
{
return false;
}
*num = (unsigned) std::stoul(str);
return true;
}
示例10: strip_file_ext
pal::string_t strip_file_ext(const pal::string_t& path)
{
if (path.empty())
{
return path;
}
size_t sep_pos = path.rfind(_X("/\\"));
size_t dot_pos = path.rfind(_X('.'));
if (sep_pos != pal::string_t::npos && sep_pos > dot_pos)
{
return path;
}
return path.substr(0, dot_pos);
}
示例11: AssertRepeatingDirSeparator
//For longpath names on windows, if the paths are normalized they are always prefixed with
//extended syntax, Windows does not do any more normalizations on this string and uses it as is
//So we should ensure that there are NO adjacent DirectorySeparatorChar
bool AssertRepeatingDirSeparator(const pal::string_t& path)
{
if (path.empty())
return true;
pal::string_t path_to_check = path;
if (LongFile::IsDevice(path))
{
path_to_check.erase(0, LongFile::DevicePathPrefix.length());
}
else if (LongFile::IsExtended(path))
{
path_to_check.erase(0, LongFile::ExtendedPrefix.length());
}
else if (LongFile::IsUNCExtended(path))
{
path_to_check.erase(0, LongFile::UNCExtendedPathPrefix.length());
}
else if (path_to_check.compare(0, LongFile::UNCPathPrefix.length(), LongFile::UNCPathPrefix) == 0)
{
path_to_check.erase(0, LongFile::UNCPathPrefix.length());
}
pal::string_t dirSeparator;
dirSeparator.push_back(LongFile::DirectorySeparatorChar);
dirSeparator.push_back(LongFile::DirectorySeparatorChar);
assert(path_to_check.find(dirSeparator) == pal::string_t::npos);
pal::string_t altDirSeparator;
altDirSeparator.push_back(LongFile::AltDirectorySeparatorChar);
altDirSeparator.push_back(LongFile::AltDirectorySeparatorChar);
assert(path_to_check.find(altDirSeparator) == pal::string_t::npos);
pal::string_t combDirSeparator1;
combDirSeparator1.push_back(LongFile::DirectorySeparatorChar);
combDirSeparator1.push_back(LongFile::AltDirectorySeparatorChar);
assert(path_to_check.find(combDirSeparator1) == pal::string_t::npos);
pal::string_t combDirSeparator2;
combDirSeparator2.push_back(LongFile::AltDirectorySeparatorChar);
combDirSeparator2.push_back(LongFile::DirectorySeparatorChar);
assert(path_to_check.find(combDirSeparator2) == pal::string_t::npos);
assert(path_to_check.find(_X("..")) == pal::string_t::npos);
return true;
}
示例12: get_deps_from_app_binary
/**
* Given path to app binary, say app.dll or app.exe, retrieve the app.deps.json.
*/
pal::string_t get_deps_from_app_binary(const pal::string_t& app_base, const pal::string_t& app)
{
pal::string_t deps_file;
auto app_name = get_filename(app);
deps_file.reserve(app_base.length() + 1 + app_name.length() + 5);
deps_file.append(app_base);
if (!app_base.empty() && app_base.back() != DIR_SEPARATOR)
{
deps_file.push_back(DIR_SEPARATOR);
}
deps_file.append(app_name, 0, app_name.find_last_of(_X(".")));
deps_file.append(_X(".deps.json"));
return deps_file;
}
示例13: get_filename
pal::string_t get_filename(const pal::string_t& path)
{
if (path.empty())
{
return path;
}
auto name_pos = path.find_last_of(DIR_SEPARATOR);
if (name_pos == pal::string_t::npos)
{
return path;
}
return path.substr(name_pos + 1);
}
示例14: to_full_path
// -----------------------------------------------------------------------------
// Given a "base" directory, yield the relative path of this file in the package
// layout.
//
// Parameters:
// base - The base directory to look for the relative path of this entry
// str - If the method returns true, contains the file path for this deps
// entry relative to the "base" directory
//
// Returns:
// If the file exists in the path relative to the "base" directory.
//
bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const
{
str->clear();
// Base directory must be present to obtain full path
if (base.empty())
{
return false;
}
pal::string_t new_base = base;
append_path(&new_base, library_name.c_str());
append_path(&new_base, library_version.c_str());
return to_rel_path(new_base, str);
}
示例15: get_deps_file
/**
* Given FX location, app binary and specified --depsfile, return deps that contains hostpolicy.dll
*/
pal::string_t get_deps_file(
const pal::string_t& fx_dir,
const pal::string_t& app_candidate,
const pal::string_t& specified_deps_file,
const runtime_config_t& config)
{
if (config.get_portable())
{
// Portable app's hostpolicy is resolved from FX deps
return fx_dir + DIR_SEPARATOR + config.get_fx_name() + _X(".deps.json");
}
else
{
// Standalone app's hostpolicy is from specified deps or from app deps.
return !specified_deps_file.empty() ? specified_deps_file : get_deps_from_app_binary(app_candidate);
}
}