version 1.5, 2007/09/17 09:28:36 |
version 1.6, 2007/09/17 12:07:22 |
|
|
|
|
static void MakeTimeStamp(void *, void *); |
static void MakeTimeStamp(void *, void *); |
static void MakeAddAllSrc(void *, void *); |
static void MakeAddAllSrc(void *, void *); |
|
static int rewrite_time(const char *); |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
|
|
return true; |
return true; |
} |
} |
|
|
|
/* touch files the hard way, by writing stuff to them */ |
|
static int |
|
rewrite_time(const char *name) |
|
{ |
|
int fd; |
|
char c; |
|
|
|
fd = open(name, O_RDWR | O_CREAT, 0666); |
|
if (fd < 0) |
|
return -1; |
|
/* |
|
* Read and write a byte to the file to change |
|
* the modification time. |
|
*/ |
|
if (read(fd, &c, 1) == 1) { |
|
(void)lseek(fd, 0, SEEK_SET); |
|
(void)write(fd, &c, 1); |
|
} |
|
|
|
(void)close(fd); |
|
return 0; |
|
} |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* Job_Touch -- |
* Job_Touch -- |
|
|
void |
void |
Job_Touch(GNode *gn, bool silent) |
Job_Touch(GNode *gn, bool silent) |
{ |
{ |
int streamID; /* ID of stream opened to do the touch */ |
|
|
|
if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL)) { |
if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL)) { |
/* |
/* |
* .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual" |
* .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual" |
|
|
const char *file = gn->path != NULL ? gn->path : gn->name; |
const char *file = gn->path != NULL ? gn->path : gn->name; |
|
|
if (set_times(file) == -1){ |
if (set_times(file) == -1){ |
streamID = open(file, O_RDWR | O_CREAT, 0666); |
if (rewrite_time(file) == -1) { |
|
|
if (streamID >= 0) { |
|
char c; |
|
|
|
/* |
|
* Read and write a byte to the file to change |
|
* the modification time, then close the file. |
|
*/ |
|
if (read(streamID, &c, 1) == 1) { |
|
(void)lseek(streamID, 0, SEEK_SET); |
|
(void)write(streamID, &c, 1); |
|
} |
|
|
|
(void)close(streamID); |
|
} else { |
|
(void)fprintf(stdout, |
(void)fprintf(stdout, |
"*** couldn't touch %s: %s", file, |
"*** couldn't touch %s: %s", file, |
strerror(errno)); |
strerror(errno)); |