Merge pull request #293 from arvidn/error_code-cleanup
clean up use of error categories
This commit is contained in:
commit
08717cb2b9
|
@ -46,13 +46,13 @@ void ed25519_create_seed(unsigned char *seed) {
|
|||
FILE *f = fopen("/dev/urandom", "rb");
|
||||
|
||||
if (f == NULL) {
|
||||
throw boost::system::system_error(boost::system::error_code(errno, boost::system::generic_category()));
|
||||
throw boost::system::system_error(boost::system::error_code(errno, boost::system::system_category()));
|
||||
}
|
||||
|
||||
int read = fread(seed, 1, 32, f);
|
||||
if (read != 32) {
|
||||
fclose(f);
|
||||
throw boost::system::system_error(boost::system::error_code(errno, boost::system::generic_category()));
|
||||
throw boost::system::system_error(boost::system::error_code(errno, boost::system::system_category()));
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
|
|
@ -205,21 +205,21 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -758,7 +758,7 @@ std::vector<std::string> list_dir(std::string path
|
|||
DIR* handle = opendir(path.c_str());
|
||||
if (handle == 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,21 +44,21 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -55,21 +55,21 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -549,7 +549,7 @@ namespace libtorrent
|
|||
m_cache_fd = open(sett.get_str(settings_pack::mmap_cache).c_str(), O_RDWR | O_CREAT | O_EXLOCK | O_TRUNC, 0700);
|
||||
if (m_cache_fd < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -561,7 +561,7 @@ namespace libtorrent
|
|||
, MAP_SHARED | MAP_NOCACHE, m_cache_fd, 0));
|
||||
if (intptr_t(m_cache_pool) == -1)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
|
||||
m_cache_pool = 0;
|
||||
// attempt to make MacOS not flush this to disk, making close()
|
||||
|
|
54
src/file.cpp
54
src/file.cpp
|
@ -393,7 +393,7 @@ namespace libtorrent
|
|||
retval = ::stat(f.c_str(), &ret);
|
||||
if (retval < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ namespace libtorrent
|
|||
if (::rename(f1.c_str(), f2.c_str()) < 0)
|
||||
#endif
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ namespace libtorrent
|
|||
std::string n = convert_to_native(f);
|
||||
int ret = mkdir(n.c_str(), 0777);
|
||||
if (ret < 0 && errno != EEXIST)
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ namespace libtorrent
|
|||
if (errno != EMLINK || errno != EXDEV)
|
||||
{
|
||||
// some error happened, report up to the caller
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,7 @@ namespace libtorrent
|
|||
// this only works on 10.5
|
||||
copyfile_state_t state = copyfile_state_alloc();
|
||||
if (copyfile(f1.c_str(), f2.c_str(), state, COPYFILE_ALL) < 0)
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
copyfile_state_free(state);
|
||||
#else
|
||||
std::string f1 = convert_to_native(inf);
|
||||
|
@ -603,7 +603,7 @@ namespace libtorrent
|
|||
int infd = ::open(f1.c_str(), O_RDONLY);
|
||||
if (infd < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ namespace libtorrent
|
|||
if (outfd < 0)
|
||||
{
|
||||
close(infd);
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
char buffer[4096];
|
||||
|
@ -627,13 +627,13 @@ namespace libtorrent
|
|||
if (num_read == 0) break;
|
||||
if (num_read < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
break;
|
||||
}
|
||||
int num_written = write(outfd, buffer, num_read);
|
||||
if (num_written < num_read)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
break;
|
||||
}
|
||||
if (num_read < int(sizeof(buffer))) break;
|
||||
|
@ -1042,7 +1042,7 @@ namespace libtorrent
|
|||
std::string const& f = convert_to_native(inf);
|
||||
if (::remove(f.c_str()) < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
#endif // TORRENT_WINDOWS
|
||||
|
@ -1137,7 +1137,7 @@ namespace libtorrent
|
|||
m_handle = opendir(p.c_str());
|
||||
if (m_handle == 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
m_done = true;
|
||||
return;
|
||||
}
|
||||
|
@ -1199,7 +1199,7 @@ namespace libtorrent
|
|||
dirent* dummy;
|
||||
if (readdir_r(m_handle, &m_dirent, &dummy) != 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
m_done = true;
|
||||
}
|
||||
if (dummy == 0) m_done = true;
|
||||
|
@ -1447,7 +1447,7 @@ namespace libtorrent
|
|||
#endif
|
||||
if (handle == -1)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
TORRENT_ASSERT(ec);
|
||||
return false;
|
||||
}
|
||||
|
@ -1693,7 +1693,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#ifdef TORRENT_WINDOWS
|
||||
ec.assign(GetLastError(), system_category());
|
||||
#else
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -1723,7 +1723,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#ifdef TORRENT_WINDOWS
|
||||
ec.assign(GetLastError(), system_category());
|
||||
#else
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -1747,7 +1747,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#else
|
||||
if (lseek(fd, file_offset, SEEK_SET) < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -1760,7 +1760,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#ifdef TORRENT_WINDOWS
|
||||
ec.assign(GetLastError(), system_category());
|
||||
#else
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -1786,7 +1786,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#ifdef TORRENT_WINDOWS
|
||||
ec = error_code(ERROR_INVALID_HANDLE, system_category());
|
||||
#else
|
||||
ec = error_code(EBADF, generic_category());
|
||||
ec = error_code(boost::system::errc::bad_file_descriptor, generic_category());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -1834,7 +1834,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
#ifdef TORRENT_WINDOWS
|
||||
ec = error_code(ERROR_INVALID_HANDLE, system_category());
|
||||
#else
|
||||
ec = error_code(EBADF, generic_category());
|
||||
ec = error_code(boost::system::errc::bad_file_descriptor, generic_category());
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -1878,7 +1878,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
&& errno != EINVAL
|
||||
&& errno != ENOSYS)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2073,7 +2073,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
struct stat st;
|
||||
if (fstat(native_handle(), &st) != 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2081,7 +2081,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
// have the right size. We don't want to update
|
||||
if (st.st_size != s && ftruncate(native_handle(), s) < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2103,14 +2103,14 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
{
|
||||
if (errno != ENOSPC)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
// ok, let's try to allocate non contiguous space then
|
||||
f.fst_flags = F_ALLOCATEALL;
|
||||
if (fcntl(native_handle(), F_PREALLOCATE, &f) < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2123,7 +2123,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
fl64.l_len = s;
|
||||
if (fcntl(native_handle(), F_ALLOCSP64, &fl64) < 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2143,7 +2143,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
// filesystem does not support this operation
|
||||
if (ret != 0 && ret != EINVAL)
|
||||
{
|
||||
ec.assign(ret, generic_category());
|
||||
ec.assign(ret, system_category());
|
||||
return false;
|
||||
}
|
||||
#endif // TORRENT_HAS_FALLOCATE
|
||||
|
@ -2166,7 +2166,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
struct stat fs;
|
||||
if (fstat(native_handle(), &fs) != 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return -1;
|
||||
}
|
||||
return fs.st_size;
|
||||
|
|
|
@ -976,7 +976,7 @@ namespace libtorrent
|
|||
{
|
||||
// failed
|
||||
m_ses.alerts().emplace_alert<read_piece_alert>(
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category()));
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ namespace libtorrent
|
|||
update_gauge();
|
||||
}
|
||||
|
||||
if (j->error.ec == error_code(boost::system::errc::not_enough_memory, generic_category()))
|
||||
if (j->error.ec == boost::system::errc::not_enough_memory)
|
||||
{
|
||||
if (alerts().should_post<file_error_alert>())
|
||||
alerts().emplace_alert<file_error_alert>(j->error.ec
|
||||
|
@ -5107,7 +5107,7 @@ namespace libtorrent
|
|||
if (flags & torrent_handle::alert_when_available)
|
||||
{
|
||||
m_ses.alerts().emplace_alert<read_piece_alert>(
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category()));
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -5243,7 +5243,7 @@ namespace libtorrent
|
|||
{
|
||||
// post an empty read_piece_alert to indicate it failed
|
||||
alerts().emplace_alert<read_piece_alert>(
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category()));
|
||||
get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category()));
|
||||
}
|
||||
if (has_picker()) m_picker->set_piece_priority(piece, 1);
|
||||
m_time_critical_pieces.erase(i);
|
||||
|
@ -5260,7 +5260,7 @@ namespace libtorrent
|
|||
{
|
||||
// post an empty read_piece_alert to indicate it failed
|
||||
m_ses.alerts().emplace_alert<read_piece_alert>(
|
||||
get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, system_category()));
|
||||
get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, generic_category()));
|
||||
}
|
||||
if (has_picker()) m_picker->set_piece_priority(i->piece, 1);
|
||||
i = m_time_critical_pieces.erase(i);
|
||||
|
@ -5279,7 +5279,7 @@ namespace libtorrent
|
|||
{
|
||||
// post an empty read_piece_alert to indicate it failed
|
||||
alerts().emplace_alert<read_piece_alert>(
|
||||
get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, system_category()));
|
||||
get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, generic_category()));
|
||||
}
|
||||
i = m_time_critical_pieces.erase(i);
|
||||
continue;
|
||||
|
@ -5982,7 +5982,7 @@ namespace libtorrent
|
|||
#if BOOST_VERSION < 105400
|
||||
if (alerts().should_post<torrent_error_alert>())
|
||||
alerts().emplace_alert<torrent_error_alert>(get_handle()
|
||||
, error_code(boost::system::errc::not_supported, system_category()), "[certificate]");
|
||||
, error_code(boost::system::errc::not_supported, generic_category()), "[certificate]");
|
||||
#else
|
||||
boost::asio::const_buffer certificate_buf(certificate.c_str(), certificate.size());
|
||||
|
||||
|
|
|
@ -49,21 +49,21 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -170,21 +170,21 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ int load_file(std::string const& filename, std::vector<char>& v, libtorrent::err
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -293,21 +293,21 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = fseek(f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
long s = ftell(f);
|
||||
if (s < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fseek(f, 0, SEEK_SET);
|
||||
if (r != 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ int load_file(std::string const& filename, std::vector<char>& v
|
|||
r = fread(&v[0], 1, v.size(), f);
|
||||
if (r < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::generic_category());
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue