diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-06 20:40:31 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-01-06 20:40:31 +0000 |
commit | 7dc6e7d63e5cffaa086f76436e39aa5d22192de8 (patch) | |
tree | d4f36beb1a6ac7c4e75360e9e3b43da00365fcfb | |
parent | 0ea258f81403300675bd625aef1becb456224e25 (diff) | |
download | drakx-7dc6e7d63e5cffaa086f76436e39aa5d22192de8.tar drakx-7dc6e7d63e5cffaa086f76436e39aa5d22192de8.tar.gz drakx-7dc6e7d63e5cffaa086f76436e39aa5d22192de8.tar.bz2 drakx-7dc6e7d63e5cffaa086f76436e39aa5d22192de8.tar.xz drakx-7dc6e7d63e5cffaa086f76436e39aa5d22192de8.zip |
tolerate file not found at creation of archives
-rw-r--r-- | mdk-stage1/mar/mar-frontend.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/mdk-stage1/mar/mar-frontend.c b/mdk-stage1/mar/mar-frontend.c index 6f15f3785..69fba17b3 100644 --- a/mdk-stage1/mar/mar-frontend.c +++ b/mdk-stage1/mar/mar-frontend.c @@ -82,8 +82,9 @@ mar_create_file(char *dest_file, char **files) { int fsiz = file_size(files[filenum]); if (fsiz == -1) - return -1; - total_length += fsiz; + files[filenum] = "FILE_NOT_FOUND&"; + else + total_length += fsiz; filenum++; } @@ -94,37 +95,39 @@ mar_create_file(char *dest_file, char **files) filenum = 0; while (files[filenum]) { - FILE * f = fopen(files[filenum], "r"); - int fsize; - if (!f) - { - perror(files[filenum]); - return -1; - } - - /* filename */ - strcpy(&(temp_marfile_buffer[current_offset_filetable]), files[filenum]); - current_offset_filetable += strlen(files[filenum]) + 1; - - /* file_length */ - fsize = file_size(files[filenum]); - if (fsize == -1) return -1; - memcpy(&temp_marfile_buffer[current_offset_filetable], &fsize, sizeof(int)); - current_offset_filetable += sizeof(int); - - /* data_offset */ - memcpy(&temp_marfile_buffer[current_offset_filetable], ¤t_offset_rawdata, sizeof(int)); - current_offset_filetable += sizeof(int); + if (strcmp(files[filenum], "FILE_NOT_FOUND&")) { + FILE * f = fopen(files[filenum], "r"); + int fsize; + if (!f) + { + perror(files[filenum]); + return -1; + } + + /* filename */ + strcpy(&(temp_marfile_buffer[current_offset_filetable]), files[filenum]); + current_offset_filetable += strlen(files[filenum]) + 1; + + /* file_length */ + fsize = file_size(files[filenum]); + if (fsize == -1) return -1; + memcpy(&temp_marfile_buffer[current_offset_filetable], &fsize, sizeof(int)); + current_offset_filetable += sizeof(int); + + /* data_offset */ + memcpy(&temp_marfile_buffer[current_offset_filetable], ¤t_offset_rawdata, sizeof(int)); + current_offset_filetable += sizeof(int); + + /* data_raw_data */ + if (fread(&temp_marfile_buffer[current_offset_rawdata], 1, fsize, f) != fsize) + { + perror(files[filenum]); + return -1; + } + fclose(f); - /* data_raw_data */ - if (fread(&temp_marfile_buffer[current_offset_rawdata], 1, fsize, f) != fsize) - { - perror(files[filenum]); - return -1; + current_offset_rawdata += fsize; } - fclose(f); - - current_offset_rawdata += fsize; filenum++; } |