Liste des Groupes | Revenir à l c |
For example:
c_file_card_unit::c_file_card_unit(ulong channel, ulong unit, const char *name,
c_logger *lp, c_card_dlp *dlp, bool punch,
bool hollerith, const char *binpath)
: c_card_unit(channel, unit, lp, dlp, punch)
{
int flags = punch?O_RDWR|O_APPEND:O_RDONLY;
int diag;
uint8 header[CARD_SIZE_COLUMNS];
f_file = NULL;
f_inputhopper = 0ul;
f_binfd = -1;
snprintf(f_binary_path, sizeof(f_binary_path), "%s", binpath);
diag = stat(name, &cu_stat);
if (diag == -1) {
if ((errno == ENOENT) && punch) {
flags |= O_CREAT|O_EXCL;
}
}
cu_fd = open(name, flags, 0600);
if (cu_fd == -1) {
fprintf(stdout, "%4.4lu/%2.2lu Unable to open '%s': %s\n",
cu_channel, cu_unit, name, strerror(errno));
return;
}
diag = fcntl(cu_fd, F_SETFD, FD_CLOEXEC);
if (diag == -1) {
lp->log("%4.4lu/%2.2lu Unable to set FD_CLOEXEC on '%s': %s\n",
cu_channel, cu_unit, name, strerror(errno));
diag = close(cu_fd);
cu_fd = -1;
return;
}
...
}
bool
c_file_card_unit::is_ready(void)
{
return (cu_fd != -1) && ((f_file != NULL) && !feof(f_file));
}
So, if is_ready() returns false after the constructor runs,
the creator of the object knows the creation failed.
Les messages affichés proviennent d'usenet.