forked from premiere/premiere-libtorrent
fix some of the build errors in examples
This commit is contained in:
parent
d308dce99b
commit
a3b18b8a41
|
@ -15,7 +15,7 @@ endif
|
|||
EXTRA_PROGRAMS = $(example_programs)
|
||||
EXTRA_DIST = Jamfile
|
||||
|
||||
client_test_SOURCES = client_test.cpp
|
||||
client_test_SOURCES = client_test.cpp print.cpp session_view.cpp torrent_view.cpp
|
||||
#client_test_LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
|
||||
|
||||
stats_counters_SOURCES = stats_counters.cpp
|
||||
|
|
|
@ -702,17 +702,19 @@ void print_alert(libtorrent::alert const* a, std::string& str)
|
|||
|
||||
int save_file(std::string const& filename, std::vector<char>& v)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
FILE* f = fopen(filename.c_str(), "wb");
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
// TODO: don't use internal file type here. use fopen()
|
||||
file f;
|
||||
error_code ec;
|
||||
if (!f.open(filename, file::write_only, ec)) return -1;
|
||||
if (ec) return -1;
|
||||
file::iovec_t b = {&v[0], v.size()};
|
||||
size_type written = f.writev(0, &b, 1, ec);
|
||||
if (written != int(v.size())) return -3;
|
||||
if (ec) return -3;
|
||||
int w = fwrite(&v[0], 1, v.size(), f);
|
||||
if (w < 0)
|
||||
{
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (w != int(v.size())) return -3;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,16 +136,19 @@ std::string const& progress_bar(int progress, int width)
|
|||
|
||||
int save_file(std::string const& filename, std::vector<char>& v)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
FILE* f = fopen(filename.c_str(), "wb");
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
file f;
|
||||
error_code ec;
|
||||
if (!f.open(filename, file::write_only, ec)) return -1;
|
||||
if (ec) return -1;
|
||||
file::iovec_t b = {&v[0], v.size()};
|
||||
size_type written = f.writev(0, &b, 1, ec);
|
||||
if (written != int(v.size())) return -3;
|
||||
if (ec) return -3;
|
||||
int w = fwrite(&v[0], 1, v.size(), f);
|
||||
if (w < 0)
|
||||
{
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (w != int(v.size())) return -3;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue