本文整理汇总了C++中Error::SetErrorToErrno方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::SetErrorToErrno方法的具体用法?C++ Error::SetErrorToErrno怎么用?C++ Error::SetErrorToErrno使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::SetErrorToErrno方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Error
File::Close ()
{
Error error;
if (StreamIsValid() && m_own_stream)
{
if (::fclose (m_stream) == EOF)
error.SetErrorToErrno();
}
if (DescriptorIsValid() && m_own_descriptor)
{
if (::close (m_descriptor) != 0)
error.SetErrorToErrno();
}
m_descriptor = kInvalidDescriptor;
m_stream = kInvalidStream;
m_options = 0;
m_own_stream = false;
m_own_descriptor = false;
m_is_interactive = eLazyBoolCalculate;
m_is_real_terminal = eLazyBoolCalculate;
return error;
}
示例2: if
Error
File::Flush ()
{
Error error;
if (StreamIsValid())
{
if (::fflush (m_stream) == EOF)
error.SetErrorToErrno();
}
else if (!DescriptorIsValid())
{
error.SetErrorString("invalid file handle");
}
return error;
}
示例3:
Error
File::Sync ()
{
Error error;
if (DescriptorIsValid())
{
if (::fsync (m_descriptor) == -1)
error.SetErrorToErrno();
}
else
{
error.SetErrorString("invalid file handle");
}
return error;
}
示例4:
static size_t
DoWriteMemory(lldb::pid_t pid, lldb::addr_t vm_addr, const void *buf,
size_t size, Error &error)
{
struct ptrace_io_desc pi_desc;
pi_desc.piod_op = PIOD_WRITE_D;
pi_desc.piod_offs = (void *)vm_addr;
pi_desc.piod_addr = (void *)buf;
pi_desc.piod_len = size;
if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0)
error.SetErrorToErrno();
return pi_desc.piod_len;
}
示例5: GetDescriptor
Error
File::Write (const void *buf, size_t &num_bytes, off_t &offset)
{
Error error;
int fd = GetDescriptor();
if (fd != kInvalidDescriptor)
{
#ifndef _WIN32
ssize_t bytes_written = -1;
do
{
bytes_written = ::pwrite (m_descriptor, buf, num_bytes, offset);
} while (bytes_written < 0 && errno == EINTR);
if (bytes_written < 0)
{
num_bytes = 0;
error.SetErrorToErrno();
}
else
{
offset += bytes_written;
num_bytes = bytes_written;
}
#else
/* FIXME:
TODO: Make sure num_bytes does not overflow.
OVERLAPPED overlapped = {};
overlapped.Offset = static_cast<DWORD>(off);
overlapped.OffsetHigh = static_cast<DWORD>(off >> 32);
WriteFile((HANDLE)_get_osfhandle(fd), to, reading, &ret, &overlapped)
*/
long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
SeekFromStart(offset);
error = Write(buf, num_bytes);
if (!error.Fail()) {
offset = ::lseek(m_descriptor, 0, SEEK_CUR);
SeekFromStart(cur);
}
#endif
}
else
{
num_bytes = 0;
error.SetErrorString("invalid file handle");
}
return error;
}
示例6:
Error
File::SeekFromEnd (off_t& offset)
{
Error error;
if (DescriptorIsValid())
{
offset = ::lseek (m_descriptor, offset, SEEK_END);
if (offset == -1)
error.SetErrorToErrno();
}
else
{
error.SetErrorString("invalid file handle");
}
return error;
}
示例7:
uint32_t
File::GetPermissions(const FileSpec &file_spec, Error &error)
{
if (file_spec)
{
struct stat file_stats;
if (::stat(file_spec.GetCString(), &file_stats) == -1)
error.SetErrorToErrno();
else
{
error.Clear();
return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
}
}
else
error.SetErrorString ("empty file spec");
return 0;
}
示例8: OpenAsReader
Error PipePosix::OpenAsReader(llvm::StringRef name,
bool child_process_inherit) {
if (CanRead() || CanWrite())
return Error("Pipe is already opened");
int flags = O_RDONLY | O_NONBLOCK;
if (!child_process_inherit)
flags |= O_CLOEXEC;
Error error;
int fd = ::open(name.data(), flags);
if (fd != -1)
m_fds[READ] = fd;
else
error.SetErrorToErrno();
return error;
}
示例9: if
Error
File::Write (const void *buf, size_t &num_bytes)
{
Error error;
ssize_t bytes_written = -1;
if (DescriptorIsValid())
{
do
{
bytes_written = ::write (m_descriptor, buf, num_bytes);
} while (bytes_written < 0 && errno == EINTR);
if (bytes_written == -1)
{
error.SetErrorToErrno();
num_bytes = 0;
}
else
num_bytes = bytes_written;
}
else if (StreamIsValid())
{
bytes_written = ::fwrite (buf, 1, num_bytes, m_stream);
if (bytes_written == 0)
{
if (::feof(m_stream))
error.SetErrorString ("feof");
else if (::ferror (m_stream))
error.SetErrorString ("ferror");
num_bytes = 0;
}
else
num_bytes = bytes_written;
}
else
{
num_bytes = 0;
error.SetErrorString("invalid file handle");
}
return error;
}
示例10: GetDescriptor
Error
File::Write (const void *buf, size_t &num_bytes, off_t &offset)
{
Error error;
int fd = GetDescriptor();
if (fd != kInvalidDescriptor)
{
#ifndef _WIN32
ssize_t bytes_written = -1;
do
{
bytes_written = ::pwrite (m_descriptor, buf, num_bytes, offset);
} while (bytes_written < 0 && errno == EINTR);
if (bytes_written < 0)
{
num_bytes = 0;
error.SetErrorToErrno();
}
else
{
offset += bytes_written;
num_bytes = bytes_written;
}
#else
long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
error = Write(buf, num_bytes);
long after = ::lseek(m_descriptor, 0, SEEK_CUR);
if (!error.Fail())
SeekFromStart(cur);
ssize_t bytes_written = after - cur;
offset = after;
#endif
}
else
{
num_bytes = 0;
error.SetErrorString("invalid file handle");
}
return error;
}
示例11: if
Error
ProcessFreeBSD::DoHalt(bool &caused_stop)
{
Error error;
if (IsStopped())
{
caused_stop = false;
}
else if (kill(GetID(), SIGSTOP))
{
caused_stop = false;
error.SetErrorToErrno();
}
else
{
caused_stop = true;
}
return error;
}
示例12: assert
Error
ProcessPOSIX::DoDestroy()
{
Error error;
if (!HasExited())
{
assert(m_monitor);
m_exit_now = true;
if (!m_monitor->Kill())
{
error.SetErrorToErrno();
return error;
}
SetPrivateState(eStateExited);
}
return error;
}
示例13: DoDestroy
Error ProcessFreeBSD::DoDestroy() {
Error error;
if (!HasExited()) {
assert(m_monitor);
m_exit_now = true;
if (GetID() == LLDB_INVALID_PROCESS_ID) {
error.SetErrorString("invalid process id");
return error;
}
if (!m_monitor->Kill()) {
error.SetErrorToErrno();
return error;
}
SetPrivateState(eStateExited);
}
return error;
}
示例14: while
Error
File::Sync ()
{
Error error;
if (DescriptorIsValid())
{
int err = 0;
do
{
err = ::fsync (m_descriptor);
} while (err == -1 && errno == EINTR);
if (err == -1)
error.SetErrorToErrno();
}
else
{
error.SetErrorString("invalid file handle");
}
return error;
}
示例15: if
Error
File::Flush ()
{
Error error;
if (StreamIsValid())
{
int err = 0;
do
{
err = ::fflush (m_stream);
} while (err == EOF && errno == EINTR);
if (err == EOF)
error.SetErrorToErrno();
}
else if (!DescriptorIsValid())
{
error.SetErrorString("invalid file handle");
}
return error;
}