#include <iostream>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#define PATH "/xxx/xxx/xxx"//复制文件所在路径
#define PATH_ "/xxx/xxx/xxx"//被复制文件路径
using namespace std;
int count=0;
char buff[1024];
void CopyFile(const char*m_path,const char*n_path);//原文件存放路径,新文件保存路径
int main()
{
CopyFile(PATH,PATH_);
return 0;
}
void CopyFile(const char*m_path,const char*n_path)
{
FILE *fp1;
FILE *fp2;
string path1=m_path;
string path2=n_path;
string path3=path2;
path3=path3+"/"+"new_file.cpp";
if(opendir(path2.c_str())==NULL)//需要被复制的路径下目录不存在
{
mkdir(path2.c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRWXG | S_IRWXO);//创建新路径下的路径
}
fp1=fopen(path1.c_str(),"r");
fp2&
Linux环境下c++实现不同路径下的文件复制
最新推荐文章于 2024-02-23 00:47:52 发布