verify that we can write to scoreboard file; if not, try to create one */ ARGUSED*/
| 2686 | /* verify that we can write to scoreboard file; if not, try to create one */ |
| 2687 | /*ARGUSED*/ |
| 2688 | void |
| 2689 | check_recordfile(const char *dir UNUSED_if_not_OS2_CODEVIEW) |
| 2690 | { |
| 2691 | const char *fq_record; |
| 2692 | int fd; |
| 2693 | |
| 2694 | #if defined(UNIX) || defined(VMS) |
| 2695 | fq_record = fqname(RECORD, SCOREPREFIX, 0); |
| 2696 | fd = open(fq_record, O_RDWR, 0); |
| 2697 | if (fd >= 0) { |
| 2698 | #ifdef VMS /* must be stream-lf to use UPDATE_RECORD_IN_PLACE */ |
| 2699 | if (!file_is_stmlf(fd)) { |
| 2700 | raw_printf("Warning: scoreboard file '%s'" |
| 2701 | " is not in stream_lf format", |
| 2702 | fq_record); |
| 2703 | wait_synch(); |
| 2704 | } |
| 2705 | #endif |
| 2706 | (void) nhclose(fd); /* RECORD is accessible */ |
| 2707 | } else if ((fd = open(fq_record, O_CREAT | O_RDWR, FCMASK)) >= 0) { |
| 2708 | (void) nhclose(fd); /* RECORD newly created */ |
| 2709 | #if defined(VMS) && !defined(SECURE) |
| 2710 | /* Re-protect RECORD with world:read+write+execute+delete access. */ |
| 2711 | (void) chmod(fq_record, FCMASK | 007); |
| 2712 | #endif /* VMS && !SECURE */ |
| 2713 | } else { |
| 2714 | raw_printf("Warning: cannot write scoreboard file '%s'", fq_record); |
| 2715 | wait_synch(); |
| 2716 | } |
| 2717 | #endif /* !UNIX && !VMS */ |
| 2718 | #if defined(MICRO) || defined(WIN32) |
| 2719 | char tmp[PATHLEN]; |
| 2720 | |
| 2721 | #ifdef OS2_CODEVIEW /* explicit path on opening for OS/2 */ |
| 2722 | /* how does this work when there isn't an explicit path or fopen |
| 2723 | * for later access to the file via fopen_datafile? ? */ |
| 2724 | (void) strncpy(tmp, dir, PATHLEN - 1); |
| 2725 | tmp[PATHLEN - 1] = '\0'; |
| 2726 | if ((strlen(tmp) + 1 + strlen(RECORD)) < (PATHLEN - 1)) { |
| 2727 | append_slash(tmp); |
| 2728 | Strcat(tmp, RECORD); |
| 2729 | } |
| 2730 | fq_record = tmp; |
| 2731 | #else |
| 2732 | Strcpy(tmp, RECORD); |
| 2733 | fq_record = fqname(RECORD, SCOREPREFIX, 0); |
| 2734 | #endif |
| 2735 | #ifdef WIN32 |
| 2736 | /* If dir is NULL it indicates create but |
| 2737 | only if it doesn't already exist */ |
| 2738 | if (!dir) { |
| 2739 | char buf[BUFSZ]; |
| 2740 | |
| 2741 | buf[0] = '\0'; |
| 2742 | fd = open(fq_record, O_RDWR); |
| 2743 | if (!(fd == -1 && errno == ENOENT)) { |
| 2744 | if (fd >= 0) { |
| 2745 | (void) nhclose(fd); |
no test coverage detected