如题,先贴图,后续上传源码和exe
测试文件大小7.08GB:
结果:
商业软件ExtremeCopy 2.1测试结果:
最新代码:
/*
* Copyright (c) purelib 2012⑵015.
*/
#include <purelib/movable_window.h>
#include <purelib/file_mapping.h>
#include <purelib/controls.h>
#include <purelib/nsconv.h>
#include <thread>
using namespace purelib;
using namespace purelib::gui;
using namespace purelib::filesystem;
#ifdef _DEBUG
#pragma comment(lib, "purelib32_d.lib")
#else
#pragma comment(lib, "purelib32.lib")
#endif
class fixed_window : public movable_window
{
public:
fixed_window()
{
append_style(WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU);
}
};
class extremely_copier : public fixed_window
{
public:
extremely_copier()
{
set_opacity(0.95f);
set_text(L"extremely_copier");
resize(700, 360);
int delta = 30;
this->input_.reset(new controls::xxedit(L"D:vs2013.4_ult_chs.iso", 17, 10, 200, 25, *this, WS_BORDER | ES_AUTOHSCROLL));
this->input_->set_font(purelib::gui::DEF_FONT_NORM_10);
this->input_->set_left(5);
this->input_->set_top(5);
this->output_.reset(new controls::xxedit(L"D:TDDOWNLOADakvs2013.4_ult_chs.iso", 17, 10, 200, 25, *this, WS_BORDER | ES_AUTOHSCROLL));
this->output_->set_font(purelib::gui::DEF_FONT_NORM_10);
this->output_->set_left(350 + 20);
this->output_->set_top(5);
this->time_used_.reset(new controls::xxedit(L"00:00:00", 17, 10, 200, 25, *this, WS_BORDER | ES_READONLY | ES_AUTOHSCROLL));
this->time_used_->set_font(purelib::gui::DEF_FONT_NORM_10);
this->time_used_->set_left(5);
this->time_used_->set_top(100);
this->launcher_.reset(new controls::xxbutton(L"启动复制", 17, 10, 118, 25, *this, WS_BORDER | BS_PUSHBUTTON));
this->launcher_->set_font(purelib::gui::DEF_FONT_BOLD_10);
this->launcher_->set_left(this->output_->get_location().x + this->output_->get_size().width);
this->launcher_->set_top(280 + 15 + delta);
this->cachesize_.reset(new controls::xxedit(L"8192", 17, 10, 200, 25, *this, WS_BORDER | ES_AUTOHSCROLL | ES_NUMBER));
this->cachesize_->set_font(purelib::gui::DEF_FONT_NORM_10);
this->cachesize_->set_left(this->output_->get_location().x + this->output_->get_size().width - delta - this->cachesize_->get_size().width);
this->cachesize_->set_top(280 + 15 + delta);
progress_.reset(new controls::xxprogressbar(17, 280, 670, 25, *this));
register_event(WM_TIMER, [this](void){
++time_used_seconds_;
auto hh = time_used_seconds_ / 3600;
auto left = time_used_seconds_ - hh * 3600;
auto mm = left / 60;
auto ss = left % 60;
static wchar_t svalue[128];
swprintf(svalue, L"%02d:%02d:%02d", hh, mm, ss);
time_used_->set_text(svalue);
});
register_event(this->launcher_->get_id(), [this](void){
// start new worker thread, avoid block UI thread.
std::thread copier([this]{
auto input = input_->get_text();
auto output = output_->get_text();
auto cachesize = atol(nsc::transcode(cachesize_->get_text()).c_str());
if (cachesize == 0)
cachesize = 8192;
launcher_->set_text(L"正在复制...");
launcher_->disable();
progress_->set_value(0);
uint64_t total_bytes = 0;
time_used_seconds_ = 0;
this->start_timer(1000);
auto start = clock();
if ((total_bytes = progress_->extremely_copy(input.c_str(), output.c_str(), cachesize)) > 0)
{
auto seconds = (clock() - start) / (long double)CLOCKS_PER_SEC;
this->stop_timer();
swprintf(message_, L"复制成功,共耗时%f秒, 平均速度%fMB/s", seconds, total_bytes / (SZ(1, M) * seconds));
MessageBox(get_handle(), message_, L"提示", MB_OK | MB_ICONINFORMATION);
}
else
{
MessageBox(get_handle(), L"复制失败", L"提示", MB_OK | MB_ICONERROR);
}
launcher_->set_text(L"启动复制");
launcher_->enable();
});
copier.detach();
});
}
private:
std::unique_ptr<controls::xxedit> input_;
std::unique_ptr<controls::xxedit> output_;
std::unique_ptr<controls::xxedit> time_used_;
std::unique_ptr<controls::xxedit> cachesize_;
std::unique_ptr<controls::xxbutton> launcher_;
std::unique_ptr<controls::xxprogressbar> progress_;
u_long time_used_seconds_;
wchar_t message_[256];
};
purelibGUIEntry
{
// enable_leak_check();
extremely_copier copier;
copier.update();
copier.show();
copier.message_loop();
return 0;
}
extremely_copier可履行文件:
http://pan.baidu.com/s/1hqEfBDU