Changeset 18ad56a8 in mainline
- Timestamp:
- 2018-06-07T15:45:56Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75701004
- Parents:
- 24fda5e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/untar/main.c
r24fda5e r18ad56a8 37 37 #include <untar.h> 38 38 39 const char *filename; 39 typedef struct { 40 const char *filename; 41 FILE *file; 42 } tar_state_t; 40 43 41 44 static int tar_open(tar_file_t *tar) 42 45 { 43 FILE *file = fopen(filename, "rb"); 44 if (file == NULL) 46 tar_state_t *state = (tar_state_t *) tar->data; 47 48 state->file = fopen(state->filename, "rb"); 49 if (state->file == NULL) 45 50 return errno; 46 51 47 tar->data = (void *) file;48 52 return EOK; 49 53 } … … 51 55 static void tar_close(tar_file_t *tar) 52 56 { 53 FILE *file = (FILE*) tar->data;54 fclose( file);57 tar_state_t *state = (tar_state_t *) tar->data; 58 fclose(state->file); 55 59 } 56 60 57 61 static size_t tar_read(tar_file_t *tar, void *data, size_t size) 58 62 { 59 FILE *file = (FILE*) tar->data;60 return fread(data, 1, size, file);63 tar_state_t *state = (tar_state_t *) tar->data; 64 return fread(data, 1, size, state->file); 61 65 } 62 66 … … 81 85 } 82 86 83 filename = argv[1]; 87 tar_state_t state; 88 state.filename = argv[1]; 89 90 tar.data = (void *) &state; 84 91 return untar(&tar); 85 92 }
Note:
See TracChangeset
for help on using the changeset viewer.