| 99 | | return NULL; |
|---|
| 100 | | |
|---|
| 101 | | print: |
|---|
| 102 | | /* Print out the file */ |
|---|
| 103 | | size=node->file_length; |
|---|
| 104 | | fseek(file, node->block_offset, SEEK_SET); |
|---|
| 105 | | for(; size > BLOCK_SIZE; size -=BLOCK_SIZE){ |
|---|
| 106 | | fread(buffer, sizeof(char), BLOCK_SIZE, file); |
|---|
| 107 | | fwrite(buffer, sizeof(char), BLOCK_SIZE, stdout); // <<< |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | fread(buffer, sizeof(char), size, file); |
|---|
| 111 | | fwrite(buffer, sizeof(char), size, stdout); // <<< |
|---|
| | 96 | return -ENOENT; |
|---|
| | 97 | |
|---|
| | 98 | read: |
|---|
| | 99 | /* Get the file length */ |
|---|
| | 100 | len=node->file_length; |
|---|
| | 101 | |
|---|
| | 102 | if (offset < len) { |
|---|
| | 103 | /* Seek to the position of the file in the tar */ |
|---|
| | 104 | fseek(file, node->block_offset, SEEK_SET); |
|---|
| | 105 | |
|---|
| | 106 | /* Seek to the requested offset */ |
|---|
| | 107 | fseek(file, offset, SEEK_CUR); |
|---|
| | 108 | |
|---|
| | 109 | /* Do the actual read */ |
|---|
| | 110 | size = fread(buffer, sizeof(char), len, file); |
|---|
| | 111 | } else |
|---|
| | 112 | size = 0; |
|---|