c kullanarak bir tar dosyası oluşturmaya çalışıyorum c. Bir nedenle benim kodudurc kütüphanesinde kütüphane kütüphanesini kullanma
system("tar -cvf xxxx.tar xxxx");
kullanamazsınız:
#include <stdio.h>
#include <libtar.h>
#include <fcntl.h>
int main(void) {
TAR *pTar;
char *tarFilename = "file.tar";
char *srcDir = "directory";
char *extractTo = ".";
tar_open(&pTar, tarFilename, NULL, O_WRONLY | O_CREAT, 0644, TAR_GNU);
tar_append_tree(pTar, srcDir, extractTo);
tar_close(pTar);
return (0);
}
Ben
tar -xvf file.tar
bir hata alıyorum ile tar istediğinizde, bu kodu çalıştırdıktan sonra
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
C kodumdaki sorun nedir?
Bu işlevi çağırmayı tamamen unuttum. @Pierre – irukeru