#ifndef _COPY2_H_
#define _COPY2_H_
#include <iostream>
#include <string>
using namespace std;
#define MAX_COPY_SIZE 4096 * 32
extern "C"
{
int file_copy(const wstring srcPath, const wstring dstPath);
long long getcopysize();
int setcopysize();
}
#endif
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include "copy2.h"
static long long copiedSize = 0;
extern "C"
{
int file_copy(const wstring srcPath, const wstring dstPath)
{
wifstream src_file;
wofstream dst_file;
src_file.open(srcPath, ios::in | ios::binary);
dst_file.open(dstPath, ios::out | ios::trunc | ios::binary);
if (src_file.is_open() != true || dst_file.is_open() != true)
{
wcout << L"open " << srcPath << L" or " << dstPath << L" is err " << std::endl;
return -1;
}
src_file.seekg(0, ios::beg);
wchar_t copyBuffer[MAX_COPY_SIZE];
streamsize count = 0;
while (!src_file.eof())
{
src_file.read(copyBuffer, MAX_COPY_SIZE);
count = src_file.gcount();
dst_file.write(copyBuffer, count);
copiedSize += count;
}
src_file.close();
dst_file.close();
return 0;
}
long long getcopysize()
{
return copiedSize;
}
int setcopysize()
{
copiedSize = 0;
return 0;
}
}