I am having issues with opening my tarfile in vim. I get this every time in my tarfile.tar file -
1 " tar.vim version v29
2 " Browsing tarfile /home/student/Documents/operSys1_hwk/hwk2/sandbox/tarfile.tar
3 " Select a file with cursor and press ENTER
4
5 tar: This does not look like a tar archive
6 tar: Exiting with failure status due to previous errors
The above is a result of entering this into the command line -
./a.out -c test.cpp > tarfile.tar
When I redirect it to a regular file without -c I get what I expect in my temp.txt file -
test.cpp^A^H^@^@^@^@^@^@^@^@^@^@¸q^F^@´<81>^@^@^A^@^@^@è^C^@^@è^C^@^@^@^@^@^@^@^@^@^@^@^@^@^@G^@
^@^@^@^P^@^@^H^@^@^@ZÌÌT^K<94>Ø)^UÌÌTò©Ê^A^UÌÌTòèu^C^@^@^
@^@^@^@^@^@This is a test
The above is a result of this entered into command line -
./a.out test.cpp > temp.txt
My code(my_tar.cpp) -
1 2 3 4 5 6 7 8
|
27 for(int i = 1; i < argc; i++){
28 if(stat(argv[i],&sb) != -1 && (S_ISREG(sb.st_mode))){
29 fp = fopen(argv[1],"r");
30 in_File = (inFile *) malloc(sizeof(inFile));
31 in_File->Contents = "This is a test";
32 printf("%s",argv[1]); //File name
33 fwrite(&sb,sizeof(sb),1,stdout); //Struct stat
34 printf("%s\n",in_File->Contents); //File contents
|
The idea is that a set of files entered on command line will be "compressed" and redirected to the tarfile.tar wherein I will write code to extract it(within same file,my_tar.cpp).