… | |
… | |
321 | |
321 | |
322 | if (force) |
322 | if (force) |
323 | m = 0; |
323 | m = 0; |
324 | |
324 | |
325 | fd = open (name, O_CREAT | O_WRONLY | O_TRUNC | m, 600); |
325 | fd = open (name, O_CREAT | O_WRONLY | O_TRUNC | m, 600); |
|
|
326 | #if defined(__MINGW32__) |
|
|
327 | _setmode(fd, _O_BINARY); |
|
|
328 | #endif |
326 | return fd; |
329 | return fd; |
327 | } |
330 | } |
328 | |
331 | |
329 | static int |
332 | static int |
330 | compose_name (const char *fname, char *oname) |
333 | compose_name (const char *fname, char *oname) |
… | |
… | |
374 | |
377 | |
375 | if (mode != lzcat) |
378 | if (mode != lzcat) |
376 | if (compose_name (fname, oname)) |
379 | if (compose_name (fname, oname)) |
377 | return -1; |
380 | return -1; |
378 | |
381 | |
|
|
382 | #if !defined(__MINGW32__) |
379 | rc = lstat (fname, &mystat); |
383 | rc = lstat (fname, &mystat); |
|
|
384 | #else |
|
|
385 | rc = stat (fname, &mystat); |
|
|
386 | #endif |
380 | fd = open (fname, O_RDONLY); |
387 | fd = open (fname, O_RDONLY); |
|
|
388 | #if defined(__MINGW32__) |
|
|
389 | _setmode(fd, _O_BINARY); |
|
|
390 | #endif |
381 | if (rc || fd == -1) |
391 | if (rc || fd == -1) |
382 | { |
392 | { |
383 | fprintf (stderr, "%s: %s: ", imagename, fname); |
393 | fprintf (stderr, "%s: %s: ", imagename, fname); |
384 | perror (""); |
394 | perror (""); |
385 | return -1; |
395 | return -1; |
… | |
… | |
421 | if (!rc && verbose) |
431 | if (!rc && verbose) |
422 | fprintf (stderr, "%s: %5.1f%% -- replaced with %s\n", |
432 | fprintf (stderr, "%s: %5.1f%% -- replaced with %s\n", |
423 | fname, nr_written == 0 ? 0 : 100.0 - nr_read / ((double) nr_written / 100.0), oname); |
433 | fname, nr_written == 0 ? 0 : 100.0 - nr_read / ((double) nr_written / 100.0), oname); |
424 | } |
434 | } |
425 | |
435 | |
|
|
436 | #if !defined(__MINGW32__) |
426 | fchmod (fd2, mystat.st_mode); |
437 | fchmod (fd2, mystat.st_mode); |
|
|
438 | #else |
|
|
439 | chmod (oname, mystat.st_mode); |
|
|
440 | #endif |
427 | close (fd); |
441 | close (fd); |
428 | close (fd2); |
442 | close (fd2); |
429 | |
443 | |
430 | if (!rc) |
444 | if (!rc) |
431 | unlink (fname); |
445 | unlink (fname); |