1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
8 struct stat sb;
9 typedef struct{
10 char *Name;
11 char *Contents;
12 }inFile;
13
14 inFile *in_File;
15 int numArgs;
16 FILE *fp;
17 char test[75];
18 char tar[3];
19
20 int main(int argc, char **argv, char **envp){
21 //Read in first few chars
22 fp = fopen(argv[1],"r");
23 stat(argv[1],&sb);
24 printf("%s\n%ld\n","this is size - ",sb.st_size);
25 in_File = (inFile *) malloc(sizeof(inFile));
26 fwrite(&sb,sizeof(sb),1,stdout);
27 fseek(fp,70, SEEK_SET);
28 fread(&test,75,1,fp);
29 printf("%s",test);
30
31 if(1==1){
32 printf("%s\n","this and that yay");
33 }else{
34 //Error check argv arrays.
35 if(argv[1] == NULL){
36 printf("%s\n","usage: ./my_tar option [files . . .]\n\t\toption = -c | -x ");
37 exit(1);
38 }
39
40 //Check files to see if they are regular.
41 for(int i = 1; i < argc; i++){
42 if(stat(argv[i],&sb) != -1 && (S_ISREG(sb.st_mode))){
43 fp = fopen(argv[i],"r");
44 in_File = (inFile *) malloc(sizeof(inFile));
45 printf("%s\n%ld\n","this is size - ",sb.st_size);
46 in_File->Contents = "test";
47 printf("%s",argv[i]);
48 fwrite(&sb,sizeof(sb),1,stdout);
49 printf("%s\n",in_File->Contents);
|