本文整理汇总了C++中FileSpec::GetPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSpec::GetPath方法的具体用法?C++ FileSpec::GetPath怎么用?C++ FileSpec::GetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSpec
的用法示例。
在下文中一共展示了FileSpec::GetPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: local_file_remover
Error
AdbClient::PullFile (const FileSpec &remote_file, const FileSpec &local_file)
{
auto error = StartSync ();
if (error.Fail ())
return error;
const auto local_file_path = local_file.GetPath ();
llvm::FileRemover local_file_remover (local_file_path.c_str ());
std::ofstream dst (local_file_path, std::ios::out | std::ios::binary);
if (!dst.is_open ())
return Error ("Unable to open local file %s", local_file_path.c_str());
const auto remote_file_path = remote_file.GetPath (false);
error = SendSyncRequest (kRECV, remote_file_path.length (), remote_file_path.c_str ());
if (error.Fail ())
return error;
std::vector<char> chunk;
bool eof = false;
while (!eof)
{
error = PullFileChunk (chunk, eof);
if (error.Fail ())
return error;
if (!eof)
dst.write (&chunk[0], chunk.size ());
}
local_file_remover.releaseFile ();
return error;
}
示例2: save_socket_id_to_file
static Error save_socket_id_to_file(const std::string &socket_id,
const FileSpec &file_spec) {
FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false);
auto error = FileSystem::MakeDirectory(temp_file_spec,
eFilePermissionsDirectoryDefault);
if (error.Fail())
return Error("Failed to create directory %s: %s",
temp_file_spec.GetCString(), error.AsCString());
llvm::SmallString<PATH_MAX> temp_file_path;
temp_file_spec.AppendPathComponent("port-file.%%%%%%");
auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetCString(),
temp_file_path);
if (err_code)
return Error("Failed to create temp file: %s", err_code.message().c_str());
llvm::FileRemover tmp_file_remover(temp_file_path.c_str());
{
std::ofstream temp_file(temp_file_path.c_str(), std::ios::out);
if (!temp_file.is_open())
return Error("Failed to open temp file %s", temp_file_path.c_str());
temp_file << socket_id;
}
err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath());
if (err_code)
return Error("Failed to rename file %s to %s: %s", temp_file_path.c_str(),
file_spec.GetPath().c_str(), err_code.message().c_str());
tmp_file_remover.releaseFile();
return Error();
}
示例3: Symlink
Error
ModuleCache::CreateHostSysRootModuleSymLink (const FileSpec &sysroot_module_path_spec, const FileSpec &module_file_path)
{
const auto error = MakeDirectory (FileSpec (sysroot_module_path_spec.GetDirectory ().AsCString (), false));
if (error.Fail ())
return error;
return FileSystem::Symlink (sysroot_module_path_spec.GetPath ().c_str (),
module_file_path.GetPath ().c_str ());
}
示例4: local_file_path
Error
AdbClient::PushFile (const FileSpec &local_file, const FileSpec &remote_file)
{
auto error = StartSync ();
if (error.Fail ())
return error;
const auto local_file_path (local_file.GetPath ());
std::ifstream src (local_file_path.c_str(), std::ios::in | std::ios::binary);
if (!src.is_open ())
return Error ("Unable to open local file %s", local_file_path.c_str());
std::stringstream file_description;
file_description << remote_file.GetPath(false).c_str() << "," << kDefaultMode;
std::string file_description_str = file_description.str();
error = SendSyncRequest (kSEND, file_description_str.length(), file_description_str.c_str());
if (error.Fail ())
return error;
char chunk[kMaxPushData];
while (!src.eof() && !src.read(chunk, kMaxPushData).bad())
{
size_t chunk_size = src.gcount();
error = SendSyncRequest(kDATA, chunk_size, chunk);
if (error.Fail ())
return Error ("Failed to send file chunk: %s", error.AsCString ());
}
error = SendSyncRequest(kDONE, local_file.GetModificationTime().seconds(), nullptr);
if (error.Fail ())
return error;
std::string response_id;
uint32_t data_len;
error = ReadSyncHeader (response_id, data_len);
if (error.Fail ())
return Error ("Failed to read DONE response: %s", error.AsCString ());
if (response_id == kFAIL)
{
std::string error_message (data_len, 0);
error = ReadAllBytes (&error_message[0], data_len);
if (error.Fail ())
return Error ("Failed to read DONE error message: %s", error.AsCString ());
return Error ("Failed to push file: %s", error_message.c_str ());
}
else if (response_id != kOKAY)
return Error ("Got unexpected DONE response: %s", response_id.c_str ());
// If there was an error reading the source file, finish the adb file
// transfer first so that adb isn't expecting any more data.
if (src.bad())
return Error ("Failed read on %s", local_file_path.c_str());
return error;
}
示例5: CreateHostSysRootModuleSymLink
Error
ModuleCache::Put (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
const FileSpec &tmp_file)
{
const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
auto error = MakeDirectory (module_spec_dir);
if (error.Fail ())
return error;
const auto module_file_path = JoinPath (module_spec_dir, module_spec.GetFileSpec ().GetFilename ().AsCString ());
const auto tmp_file_path = tmp_file.GetPath ();
const auto err_code = llvm::sys::fs::copy_file (tmp_file_path.c_str (), module_file_path.GetPath ().c_str ());
if (err_code)
{
error.SetErrorStringWithFormat ("failed to copy file %s to %s: %s",
tmp_file_path.c_str (),
module_file_path.GetPath ().c_str (),
err_code.message ().c_str ());
}
// Create sysroot link to a module.
const auto sysroot_module_path_spec = GetHostSysRootModulePath (root_dir_spec, hostname, module_spec.GetFileSpec ());
return CreateHostSysRootModuleSymLink (sysroot_module_path_spec, module_file_path);
}
示例6: Error
Error
AdbClient::Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime)
{
auto error = StartSync ();
if (error.Fail ())
return error;
const std::string remote_file_path (remote_file.GetPath (false));
error = SendSyncRequest (kSTAT, remote_file_path.length (), remote_file_path.c_str ());
if (error.Fail ())
return Error ("Failed to send request: %s", error.AsCString ());
static const size_t stat_len = strlen (kSTAT);
static const size_t response_len = stat_len + (sizeof (uint32_t) * 3);
std::vector<char> buffer (response_len);
error = ReadAllBytes (&buffer[0], buffer.size ());
if (error.Fail ())
return Error ("Failed to read response: %s", error.AsCString ());
DataExtractor extractor (&buffer[0], buffer.size (), eByteOrderLittle, sizeof (void*));
offset_t offset = 0;
const void* command = extractor.GetData (&offset, stat_len);
if (!command)
return Error ("Failed to get response command");
const char* command_str = static_cast<const char*> (command);
if (strncmp (command_str, kSTAT, stat_len))
return Error ("Got invalid stat command: %s", command_str);
mode = extractor.GetU32 (&offset);
size = extractor.GetU32 (&offset);
mtime = extractor.GetU32 (&offset);
return Error ();
}
示例7: json_parser
StructuredData::ObjectSP
StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) {
StructuredData::ObjectSP return_sp;
auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath());
if (!buffer_or_error) {
error.SetErrorStringWithFormatv("could not open input file: {0} - {1}.",
input_spec.GetPath(),
buffer_or_error.getError().message());
return return_sp;
}
JSONParser json_parser(buffer_or_error.get()->getBuffer());
return_sp = ParseJSONValue(json_parser);
return return_sp;
}
示例8: sizeof
bool
PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
{
if (!m_pairs.empty())
{
char orig_path[PATH_MAX];
char new_path[PATH_MAX];
const size_t orig_path_len = orig_spec.GetPath (orig_path, sizeof(orig_path));
if (orig_path_len > 0)
{
const_iterator pos, end = m_pairs.end();
for (pos = m_pairs.begin(); pos != end; ++pos)
{
const size_t prefix_len = pos->first.GetLength();
if (orig_path_len >= prefix_len)
{
if (::strncmp (pos->first.GetCString(), orig_path, prefix_len) == 0)
{
const size_t new_path_len = snprintf(new_path, sizeof(new_path), "%s/%s", pos->second.GetCString(), orig_path + prefix_len);
if (new_path_len < sizeof(new_path))
{
new_spec.SetFile (new_path, true);
if (new_spec.Exists())
return true;
}
}
}
}
}
}
new_spec.Clear();
return false;
}
示例9: user_dirs
void
PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch (std::vector<lldb_private::FileSpec> &directories)
{
FileSpecList user_dirs(GetGlobalProperties()->GetKextDirectories());
std::vector<FileSpec> possible_sdk_dirs;
const uint32_t user_dirs_count = user_dirs.GetSize();
for (uint32_t i = 0; i < user_dirs_count; i++)
{
FileSpec dir = user_dirs.GetFileSpecAtIndex (i);
dir.ResolvePath();
if (dir.Exists() && dir.IsDirectory())
{
directories.push_back (dir);
possible_sdk_dirs.push_back (dir); // does this directory have a *.sdk or *.kdk that we should look in?
// Is there a "System/Library/Extensions" subdir of this directory?
std::string dir_sle_path = dir.GetPath();
dir_sle_path.append ("/System/Library/Extensions");
FileSpec dir_sle(dir_sle_path.c_str(), true);
if (dir_sle.Exists() && dir_sle.IsDirectory())
{
directories.push_back (dir_sle);
}
}
}
SearchSDKsForKextDirectories (possible_sdk_dirs, directories);
}
示例10: GetSymbolFile
Error PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file) {
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
char resolved_path[PATH_MAX];
const char *sdk_dir = GetSDKDirectoryAsCString();
if (sdk_dir) {
::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", sdk_dir,
platform_file_path);
// First try in the SDK and see if the file is in there
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
return error;
// Else fall back to the actual path itself
local_file.SetFile(platform_file_path, true);
if (local_file.Exists())
return error;
}
error.SetErrorStringWithFormat(
"unable to locate a platform file for '%s' in platform '%s'",
platform_file_path, GetPluginName().GetCString());
} else {
error.SetErrorString("invalid platform file argument");
}
return error;
}
示例11: GetLogIfAnyCategoriesSet
bool
PlatformRemoteGDBServer::GetModuleSpec (const FileSpec& module_file_spec,
const ArchSpec& arch,
ModuleSpec &module_spec)
{
Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
const auto module_path = module_file_spec.GetPath (false);
if (!m_gdb_client.GetModuleInfo (module_file_spec, arch, module_spec))
{
if (log)
log->Printf ("PlatformRemoteGDBServer::%s - failed to get module info for %s:%s",
__FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str ());
return false;
}
if (log)
{
StreamString stream;
module_spec.Dump (stream);
log->Printf ("PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s",
__FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str (), stream.GetString ().c_str ());
}
return true;
}
示例12: GetSymbolFile
Error PlatformRemoteAppleWatch::GetSymbolFile(const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
char resolved_path[PATH_MAX];
const char *os_version_dir = GetDeviceSupportDirectoryForOSVersion();
if (os_version_dir) {
::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists()) {
if (log) {
log->Printf("Found a copy of %s in the DeviceSupport dir %s",
platform_file_path, os_version_dir);
}
return error;
}
::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s",
os_version_dir, platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists()) {
if (log) {
log->Printf(
"Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal",
platform_file_path, os_version_dir);
}
return error;
}
::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
os_version_dir, platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists()) {
if (log) {
log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols",
platform_file_path, os_version_dir);
}
return error;
}
}
local_file = platform_file;
if (local_file.Exists())
return error;
error.SetErrorStringWithFormat(
"unable to locate a platform file for '%s' in platform '%s'",
platform_file_path, GetPluginName().GetCString());
} else {
error.SetErrorString("invalid platform file argument");
}
return error;
}
示例13:
llvm::sys::TimePoint<>
FileSystem::GetModificationTime(const FileSpec &file_spec) {
llvm::sys::fs::file_status status;
std::error_code ec = llvm::sys::fs::status(file_spec.GetPath(), status);
if (ec)
return llvm::sys::TimePoint<>();
return status.getLastModificationTime();
}
示例14: GetDeviceSupportDirectoryForOSVersion
Error
PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file)
{
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
{
char resolved_path[PATH_MAX];
const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
if (os_version_dir)
{
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/%s",
os_version_dir,
platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
return error;
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols.Internal/%s",
os_version_dir,
platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
return error;
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols/%s",
os_version_dir,
platform_file_path);
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
return error;
}
local_file = platform_file;
if (local_file.Exists())
return error;
error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
platform_file_path,
GetPluginName().GetCString());
}
else
{
error.SetErrorString ("invalid platform file argument");
}
return error;
}
示例15: sle_kext_directory_path
FileSpec::EnumerateDirectoryResult
PlatformDarwinKernel::GetKextDirectoriesInSDK (void *baton,
FileSpec::FileType file_type,
const FileSpec &file_spec)
{
if (file_type == FileSpec::eFileTypeDirectory
&& (file_spec.GetFileNameExtension() == ConstString("sdk")
|| file_spec.GetFileNameExtension() == ConstString("kdk")))
{
std::string kext_directory_path = file_spec.GetPath();
// Append the raw directory path, e.g. /Library/Developer/KDKs/KDK_10.10_14A298i.kdk
// to the directory search list -- there may be kexts sitting directly
// in that directory instead of being in a System/Library/Extensions subdir.
((std::vector<lldb_private::FileSpec> *)baton)->push_back(file_spec);
// Check to see if there is a System/Library/Extensions subdir & add it if it exists
std::string sle_kext_directory_path (kext_directory_path);
sle_kext_directory_path.append ("/System/Library/Extensions");
FileSpec sle_kext_directory (sle_kext_directory_path.c_str(), true);
if (sle_kext_directory.Exists() && sle_kext_directory.IsDirectory())
{
((std::vector<lldb_private::FileSpec> *)baton)->push_back(sle_kext_directory);
}
// Check to see if there is a Library/Extensions subdir & add it if it exists
std::string le_kext_directory_path (kext_directory_path);
le_kext_directory_path.append ("/Library/Extensions");
FileSpec le_kext_directory (le_kext_directory_path.c_str(), true);
if (le_kext_directory.Exists() && le_kext_directory.IsDirectory())
{
((std::vector<lldb_private::FileSpec> *)baton)->push_back(le_kext_directory);
}
// Check to see if there is a System/Library/Kernels subdir & add it if it exists
std::string slk_kernel_path (kext_directory_path);
slk_kernel_path.append ("/System/Library/Kernels");
FileSpec slk_kernel_directory (slk_kernel_path.c_str(), true);
if (slk_kernel_directory.Exists() && slk_kernel_directory.IsDirectory())
{
((std::vector<lldb_private::FileSpec> *)baton)->push_back(slk_kernel_directory);
}
// Check to see if there is a System/Library/Extensions/KDK subdir & add it if it exists
std::string slek_kernel_path (kext_directory_path);
slek_kernel_path.append ("/System/Library/Extensions/KDK");
FileSpec slek_kernel_directory (slek_kernel_path.c_str(), true);
if (slek_kernel_directory.Exists() && slek_kernel_directory.IsDirectory())
{
((std::vector<lldb_private::FileSpec> *)baton)->push_back(slek_kernel_directory);
}
}
return FileSpec::eEnumerateDirectoryResultNext;
}