代码拉取完成,页面将自动刷新
同步操作将从 Smalli/filesclassify 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "copyfiles.h"
copyFiles::copyFiles(QObject *parent) : QObject(parent)
{
is_exit = false;
video_filters << "*.avi"<<"*.flv"<<"*.mpg"<<"*.mpeg"<<"*.mpe"<<"*.m1v"<<"*.m2v"<<"*.mpv2"<<"*.mp2v"<<"*.dat"<<"*.ts"<<"*.mp4"<<"*.m4v"<<
"*.m4p"<<"*.m4b"<<"*.3gp"<<"*.3gpp"<<"*.3g2"<<"*.3gp2"<<"*.ogg"<<"*.mov"<<"*.rm"<<"*.rmvb"<<"*.mkv";
picture_filters << "*.jpg" << "*.jpeg" << "*.png" << "*.bmp" << "*.gif" << "*.wmf" << "*.ico" << "*.psd";
all_filters << video_filters;
all_filters << picture_filters;
}
QStringList copyFiles::getVideoFilters()
{
return video_filters;
}
QStringList copyFiles::getPictureFilters()
{
return picture_filters;
}
void copyFiles::stopCopyFiles()
{
is_exit = true;
}
void copyFiles::startCopyFiles(QString dst,QStringList *file_list,uint8_t classify_type,bool is_remove,bool ignore_same)
{
QString pic_dir = dst + "/图片";
QString video_dir = dst + "/视频";
QString dst_path,mk_dir,type;
uint64_t total_files = file_list->length();
uint64_t pic_files = 0;
uint64_t video_files = 0;
uint64_t pic_files_success = 0;
uint64_t video_files_success = 0;
uint64_t index = 0;
is_exit = false;
emit setTotalPbRange(total_files);
foreach(QString src_file_path,*file_list)
{
if(is_exit)
break;
index++;
emit setTotalPbValue(index);
QFileInfo src_file_info(src_file_path);
type = "*." + src_file_info.suffix();
QDateTime lt;
if(classify_type == 0)
{
lt = src_file_info.birthTime().toLocalTime();
}
else
{
lt = src_file_info.lastModified().toLocalTime();
}
mk_dir = lt.toString("yyyy/MM");
emit setCurrentPbRange(src_file_info.size());
emit setCurrentPbValue(0);
QString type_dir;
if(picture_filters.contains(type))
{
type_dir = pic_dir;
pic_files++;
}
else if(video_filters.contains(type))
{
type_dir = video_dir;
video_files++;
}
else
continue;
dst_path = type_dir + "/" + mk_dir;
QFileInfo dst_info(dst_path);
QDir d;
if(!dst_info.isDir())
d.mkpath(dst_path);
dst_path += "/";
dst_path += src_file_info.fileName();
dst_info.setFile(dst_path);
if(dst_info.exists())
{
// if(picture_filters.contains(type))
// {
// pic_files++;
// }
// else if(video_filters.contains(type))
// {
// video_files++;
// }
if(ignore_same)
continue;
QFile f(dst_path);
f.remove();
}
QFile ifile,ofile;
uint64_t c_size = 0;
ifile.setFileName(src_file_path);
if(!ifile.open(QIODevice::ReadOnly))
{
}
QDataStream infile(&ifile);
infile.setVersion(QDataStream::Qt_5_15);
ofile.setFileName(dst_path);
if(!ofile.open(QIODevice::WriteOnly))
{
}
QDataStream outfile(&ofile);
outfile.setVersion(QDataStream::Qt_5_15);
char byteTemp[4096];
int readSize = 0;
infile.resetStatus();
outfile.resetStatus();
while(!infile.atEnd())
{
readSize = infile.readRawData(byteTemp, 4096);
outfile.writeRawData(byteTemp, readSize);
c_size += readSize;
emit setCurrentPbValue(c_size);
}
ifile.close();
ofile.close();
if(is_remove)
ifile.remove();
// if(!QFile::copy(src_file_path,dst_path))
// {
// qDebug() << "复制失败";
// continue;
// }
if(picture_filters.contains(type))
{
pic_files_success++;
}
else if(video_filters.contains(type))
{
video_files_success++;
}
}
QString result_str;
// result_str = QString("共%1个文件- %2 成功, %3 失败\r\n").arg(total_files).arg(index).arg(total_files - index);
// result_str += QString("图片 %1 个- %2 成功, %3 失败\r\n").arg(pic_files).arg(pic_files_success).arg(pic_files - pic_files_success);
// result_str += QString("视频 %1 个- %2 成功, %3 失败\r\n").arg(video_files).arg(video_files_success).arg(video_files - video_files_success);
result_str = QString("共处理 %1个文件\r\n").arg(index);
result_str += QString("图片 %1 个\r\n").arg(pic_files);
result_str += QString("视频 %1 个\r\n").arg(video_files);
if(is_exit)
emit copyStop(result_str);
else
emit copyEnd(result_str);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。