1.通过c直接实现

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int fileNum=0;
char fileNam[10];

char fileName(){
    fileNam[10]=0;
    fileNum += 1;
    char str[4];
    char s1[]="./image/";
    char s2[]=".yuv";
    sprintf(str,"%d",fileNum);
    sprintf(fileNam,"%s%s%s",s1,str,s2);     
}

int main(int argc,char* argv[])
{
    int fd_src,fd_dst;
    char buf[245120];
    int n;
    
    if((fd_src=open("./raw.data",O_RDONLY))<0)
    {
        perror("open src");
        exit(EXIT_FAILURE);
    }
    
    while((n=read(fd_src,buf,sizeof(buf)))>0){
        if (n != 245120)
        {
            perror("file size small");
            close(fd_src);
            exit(EXIT_FAILURE);
        }

        //lseek(fd_src,245120,SEEK_CUR);
        fileName();    
                
        if (fd_dst = open(fileNam,O_CREAT|O_WRONLY,0666)<0)
        {
            perror("open dst fail");
            close(fd_src);
            exit(EXIT_FAILURE);
        }
    
        write(fd_dst,buf,n);
    
        printf("copy successfully\n");
        close(fd_dst);
        system("./move.sh");
    }
    printf("copy successfully\n");
    close(fd_src);
    exit(EXIT_SUCCESS);    
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-02-10
  • 2021-08-30
  • 2021-06-21
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-11-22
  • 2022-02-07
相关资源
相似解决方案