version 1.15, 2004/08/13 13:24:13 |
version 1.16, 2004/08/27 15:44:38 |
|
|
} |
} |
|
|
/* only keep a pointer to the open file if we're in writing mode */ |
/* only keep a pointer to the open file if we're in writing mode */ |
if ((flags & O_WRONLY) || (flags & O_RDWR)) { |
if ((flags & O_WRONLY) || (flags & O_RDWR)) |
ep->cef_flags |= CVS_ENTF_WR; |
ep->cef_flags |= CVS_ENTF_WR; |
ep->cef_file = fp; |
|
} |
|
else |
|
(void)fclose(fp); |
|
|
|
|
(void)fclose(fp); |
|
|
if (exists) |
if (exists) |
ep->cef_flags |= CVS_ENTF_SYNC; |
ep->cef_flags |= CVS_ENTF_SYNC; |
|
|
|
|
int |
int |
cvs_ent_add(CVSENTRIES *ef, struct cvs_ent *ent) |
cvs_ent_add(CVSENTRIES *ef, struct cvs_ent *ent) |
{ |
{ |
if (ef->cef_file == NULL) { |
if (!(ef->cef_flags & CVS_ENTF_WR)) { |
cvs_log(LP_ERR, "Entries file is opened in read-only mode"); |
cvs_log(LP_ERR, "Entries file is opened in read-only mode"); |
return (-1); |
return (-1); |
} |
} |
|
|
{ |
{ |
struct cvs_ent *ent; |
struct cvs_ent *ent; |
|
|
if (ef->cef_file == NULL) { |
if (!(ef->cef_flags & CVS_ENTF_WR)) { |
cvs_log(LP_ERR, "Entries file is opened in read-only mode"); |
cvs_log(LP_ERR, "Entries file is opened in read-only mode"); |
return (-1); |
return (-1); |
} |
} |
|
|
{ |
{ |
struct cvs_ent *ent; |
struct cvs_ent *ent; |
|
|
|
if (!(ef->cef_flags & CVS_ENTF_WR)) { |
|
cvs_log(LP_ERR, "Entries file is opened in read-only mode"); |
|
return (-1); |
|
} |
|
|
ent = cvs_ent_get(ef, name); |
ent = cvs_ent_get(ef, name); |
if (ent == NULL) |
if (ent == NULL) |
return (-1); |
return (-1); |
|
|
char revbuf[64], timebuf[32]; |
char revbuf[64], timebuf[32]; |
struct cvs_ent *ent; |
struct cvs_ent *ent; |
|
|
if (ef->cef_file == NULL) |
|
return (-1); |
|
|
|
if (ef->cef_flags & CVS_ENTF_SYNC) |
if (ef->cef_flags & CVS_ENTF_SYNC) |
return (0); |
return (0); |
|
|
|
if (ef->cef_file == NULL) { |
|
ef->cef_file = fopen(ef->cef_path, "w"); |
|
if (ef->cef_file == NULL) { |
|
cvs_log(LP_ERRNO, "failed to open Entries `%s'", |
|
ef->cef_path); |
|
return (-1); |
|
} |
|
} |
|
|
|
|
/* reposition ourself at beginning of file */ |
/* reposition ourself at beginning of file */ |
rewind(ef->cef_file); |
rewind(ef->cef_file); |
TAILQ_FOREACH(ent, &(ef->cef_ent), ce_list) { |
TAILQ_FOREACH(ent, &(ef->cef_ent), ce_list) { |
|
|
fprintf(ef->cef_file, "D\n"); |
fprintf(ef->cef_file, "D\n"); |
|
|
ef->cef_flags |= CVS_ENTF_SYNC; |
ef->cef_flags |= CVS_ENTF_SYNC; |
|
fclose(ef->cef_file); |
|
ef->cef_file = NULL; |
|
|
return (0); |
return (0); |
} |
} |