?? NEWTITLE := 'NOS/VE : Basic Access Methods : Create File' ??
MODULE bam$create_file;
?? RIGHT := 110 ??

{ Purpose:
{   Request to create a file.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc ame$attribute_validation_errors
*copyc dmt$allocation_size
*copyc dmt$class
*copyc dmt$transfer_size
*copyc fmt$removable_media_req_info
*copyc fsc$local
*copyc fse$create_validation_errors
*copyc cle$ecc_file_reference
*copyc fst$attachment_options
*copyc fst$device_attributes
*copyc fst$file_attributes
*copyc fst$file_cycle_attributes
*copyc oss$job_paged_literal
*copyc ost$caller_identifier
*copyc pfc$null_shared_queue
*copyc pfe$error_condition_codes
*copyc rme$request_tape
?? POP ??
*copyc bap$fetch_tape_validation
*copyc bap$process_pt_request
*copyc bap$set_evaluated_file_abnormal
*copyc clp$convert_file_ref_to_string
*copyc clp$convert_string_to_file_ref
*copyc clp$convert_integer_to_string
*copyc fmp$request_mass_storage
*copyc fmp$is_file_attached
*copyc fmv$default_file_attributes
*copyc fsp$path_element
*copyc fsp$set_evaluated_file_abnormal
*copyc fsp$validate_attributes
*copyc osp$append_status_integer
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc osp$set_status_condition
*copyc osp$verify_system_privilege
*copyc pfi$convert_password
*copyc pfp$convert_fs_to_pft$path
*copyc pfp$convert_shared_queue_to_ord
*copyc pfp$r3_define_mass_storage
*copyc rmp$build_mass_storage_info
*copyc rmp$complete_tape_request
*copyc rmp$validate_ansi_string
*copyc rmp$validate_mass_storage_info
*copyc rmp$validate_tape_request
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Declared by This Module', EJECT ??

  CONST
    include_radix = TRUE,
    radix = 10;

  VAR
    file_attribute_names: [STATIC, READ, oss$job_paged_literal] array
          [fsc$attachment_logging .. fsc$file_password] of ost$name := [
{ fsc$attachment_logging ......... = 001} 'ATTACHMENT_LOGGING           ',
{ fsc$file_password .............. = 002} 'FILE_PASSWORD                '];

  VAR
    write_selections: [oss$job_paged_literal, READ] fst$file_access_options :=
          [fsc$shorten, fsc$append, fsc$modify];

  VAR
    v$log: [oss$job_paged_literal, READ] array [boolean] of pft$log := [
{ FALSE } pfc$no_log,
{ TRUE  } pfc$log];

?? TITLE := 'PROCEDURE [XDCL, #GATE] bap$create_file', EJECT ??

  PROCEDURE [XDCL, #GATE] bap$create_file
    (    attachment_options: ^fst$attachment_options;
         cycle_attributes: ^fst$file_cycle_attributes;
         file_attributes: ^fst$file_attributes;
         device_attributes: ^fst$device_attributes;
     VAR evaluated_file_reference: {i/o} fst$evaluated_file_reference;
     VAR resolved_path: fst$path;
     VAR status: ost$status);

    VAR
      allocation_size: rmt$allocation_size,
      attached: boolean,
      attachment_logging: boolean,
      attachment_options_index: integer,
      caller_id: ost$caller_identifier,
      catalog_cycle_attributes: pft$catalog_cycle_attributes,
      density: rmt$density,
      device_class: fst$device_class,
      estimated_file_size: amt$file_byte_address,
      file_password: pft$password,
      ignore_pt_results: bat$process_pt_results,
      initial_volume: rmt$recorded_vsn,
      mass_storage_class: rmt$mass_storage_class,
      mass_storage_request_info: fmt$mass_storage_request_info,
      number_of_volumes: integer,
      parsed_file_reference: fst$parsed_file_reference,
      path_length: fst$path_size,
      p_path: ^pft$path,
      p_volume_list: ^rmt$volume_list,
      path: fst$path,
      path_size: fst$path_size,
      pf_cycle: pft$cycle_selector,
      removable_media_group: ost$name,
      removable_media_req_info: fmt$removable_media_req_info,
      shared_queue: pft$shared_queue,
      tape_validation: boolean,
      transfer_size: fst$transfer_size,
      validation_state: bat$tape_validation_state,
      volume_list: ^rmt$volume_list,
      volume_list_index: integer,
      volume_overflow_allowed: boolean,
      work_list: bat$process_pt_work_list,
      write_ring: rmt$write_ring;

?? NEWTITLE := 'P$ADD_PATH_INTEGER', EJECT ??

    PROCEDURE [INLINE] p$add_path_integer
      (VAR result: fst$path;
       VAR path_size: fst$path_size;
           int: integer);

      VAR
        str: ost$string;

      clp$convert_integer_to_string (int, 10, FALSE, str, status);
      IF NOT status.normal THEN
        EXIT bap$create_file; {----->
      IFEND;

      IF path_size + str.size <= fsc$max_path_size THEN
        result (path_size + 1, str.size) := str.value;
        path_size := path_size + str.size;
      ELSE
        osp$set_status_condition (cle$file_reference_too_long, status);
        EXIT bap$create_file; {----->
      IFEND;

    PROCEND p$add_path_integer;
?? OLDTITLE ??
?? NEWTITLE := '    STATUS_REPORTING_PROCEDURE', EJECT ??

    PROCEDURE status_reporting_procedure
      (    condition: ost$status_condition;
           text: string ( * );
       VAR status: ost$status);

      fsp$set_evaluated_file_abnormal (evaluated_file_reference, condition, fsc$create_file_req, text,
            status);

    PROCEND status_reporting_procedure;
?? OLDTITLE ??
?? NEWTITLE := 'PROCEDURE [INLINE] validate_cycle_attributes', EJECT ??

    PROCEDURE [INLINE] validate_cycle_attributes
      (    evaluated_file_reference: fst$evaluated_file_reference;
           cycle_attributes: ^fst$file_cycle_attributes;
       VAR catalog_cycle_attributes: pft$catalog_cycle_attributes;
       VAR status: ost$status);

      CONST
        create_file_request = 'FSP$CREATE_FILE',
        cycle_attributes_parameter = 'FILE_CYCLE_ATTRIBUTES';

      VAR
        cycle_attribute_index: integer,
        cycle_attribute_name: ost$name;

      status.normal := TRUE;

      IF fmv$default_new_retention = NIL THEN
        catalog_cycle_attributes.retention.selector := fsc$retention_day_increment;
        catalog_cycle_attributes.retention.day_increment := 999;
      ELSE
        catalog_cycle_attributes.retention := fmv$default_new_retention^;
      IFEND;

      catalog_cycle_attributes.retrieve_option := pfc$always_retrieve;
      catalog_cycle_attributes.site_backup_option := pfc$null_site_backup_option;
      catalog_cycle_attributes.site_archive_option := pfc$null_site_archive_option;
      catalog_cycle_attributes.site_release_option := pfc$null_site_release_option;

      IF cycle_attributes = NIL THEN
        RETURN; {----->
      IFEND;

      FOR cycle_attribute_index := 1 TO UPPERBOUND (cycle_attributes^) DO
        CASE cycle_attributes^ [cycle_attribute_index].selector OF
        = fsc$retention =
        = fsc$retrieve_option =
        = fsc$site_backup_option =
        = fsc$site_archive_option =
        = fsc$site_release_option =
        = fsc$null_attribute =
          ;
        ELSE
          bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_file_attrib_key,
                create_file_request, cycle_attributes_parameter, status);
          osp$append_status_integer (osc$status_parameter_delimiter, cycle_attribute_index, radix,
                NOT include_radix, status);
          RETURN; {----->
        CASEND;
      FOREND;

      fsp$validate_attributes (cycle_attributes, 'CYCLE_ATTRIBUTES', ^status_reporting_procedure, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;

      FOR cycle_attribute_index := 1 TO UPPERBOUND (cycle_attributes^) DO
        CASE cycle_attributes^ [cycle_attribute_index].selector OF
        = fsc$retention =
          catalog_cycle_attributes.retention := cycle_attributes^ [cycle_attribute_index].retention;
        = fsc$retrieve_option =
          catalog_cycle_attributes.retrieve_option := cycle_attributes^ [cycle_attribute_index].
                retrieve_option;
        = fsc$site_backup_option =
          catalog_cycle_attributes.site_backup_option := cycle_attributes^ [cycle_attribute_index].
                site_backup_option;
        = fsc$site_archive_option =
          catalog_cycle_attributes.site_archive_option := cycle_attributes^ [cycle_attribute_index].
                site_archive_option;
        = fsc$site_release_option =
          catalog_cycle_attributes.site_release_option := cycle_attributes^ [cycle_attribute_index].
                site_release_option;
        = fsc$null_attribute =
          ;
        CASEND;
      FOREND;

    PROCEND validate_cycle_attributes;

?? OLDTITLE ??
?? NEWTITLE := 'PROCEDURE [INLINE] validate_device_attributes', EJECT ??

    PROCEDURE [INLINE] validate_device_attributes
      (    evaluated_file_reference: fst$evaluated_file_reference;
           device_attributes: ^fst$device_attributes;
       VAR allocation_size: rmt$allocation_size;
       VAR density: rmt$density;
       VAR device_class: fst$device_class;
       VAR estimated_file_size: amt$file_byte_address;
       VAR initial_volume: rmt$recorded_vsn;
       VAR mass_storage_class: rmt$mass_storage_class;
       VAR removable_media_group: ost$name;
       VAR shared_queue: pft$shared_queue;
       VAR transfer_size: fst$transfer_size;
       VAR volume_list: ^rmt$volume_list;
       VAR volume_overflow_allowed: boolean;
       VAR status: ost$status);

      CONST
        create_file_request = 'FSP$CREATE_FILE',
        device_attributes_parameter = 'DEVICE_ATTRIBUTES',
        request_mass_storage = 'RMP$REQUEST_MASS_STORAGE',
        request_tape = 'RMP$REQUEST_TAPE';

      VAR
        attribute_value_is_good: boolean,
        device_attribute_index: integer,
        device_attribute_name: ost$name,
        device_attribute_p: ^fst$device_attribute,
        local_status: ost$status,
        valid_name: boolean,
        volume_list_index: integer;

      status.normal := TRUE;

      allocation_size := rmc$unspecified_allocation_size;
      density := rmc$6250;
      device_class := fsc$mass_storage_device;
      estimated_file_size := rmc$unspecified_file_size;
      initial_volume := rmc$unspecified_vsn;
      mass_storage_class := rmc$unspecified_file_class;
      shared_queue := pfc$null_shared_queue;
      transfer_size := rmc$unspecified_transfer_size;
      volume_list := NIL;
      volume_overflow_allowed := TRUE;

      IF device_attributes = NIL THEN
        RETURN; {----->
      IFEND;

      device_attribute_name := osc$null_name;

      FOR device_attribute_index := 1 TO UPPERBOUND (device_attributes^) DO
        device_attribute_p := ^device_attributes^ [device_attribute_index];

        CASE device_attribute_p^.selector OF
        = fsc$allocation_size =
          IF device_attribute_p^.allocation_size > UPPERVALUE (dmt$allocation_size) THEN
            allocation_size := dmc$max_bytes_per_allocation;
          ELSEIF (device_attribute_p^.allocation_size >= LOWERVALUE (rmt$allocation_size)) AND
                (device_attribute_p^.allocation_size <= UPPERVALUE (rmt$allocation_size)) THEN
            allocation_size := device_attribute_p^.allocation_size;
          ELSE
            device_attribute_name := 'ALLOCATION_SIZE';
            status.normal := FALSE;
          IFEND;

        = fsc$density =
          IF (device_attribute_p^.density < LOWERVALUE (rmt$density)) OR
                (device_attribute_p^.density > UPPERVALUE (rmt$density)) THEN
            bap$set_evaluated_file_abnormal (evaluated_file_reference, rme$improper_density_value,
                  request_tape, '', status);
            RETURN; {----->
          ELSE
            density := device_attribute_p^.density;
          IFEND;

        = fsc$device_class =
          IF (device_attribute_p^.device_class < LOWERVALUE (fst$device_class)) OR
                (device_attribute_p^.device_class > UPPERVALUE (fst$device_class)) OR
                ((device_attribute_p^.device_class <> fsc$mass_storage_device) AND
                (device_attribute_p^.device_class <> fsc$magnetic_tape_device)) THEN
            bap$set_evaluated_file_abnormal (evaluated_file_reference, fse$improper_device_class_value,
                  create_file_request, '', status);
            RETURN; {----->
          ELSE
            device_class := device_attribute_p^.device_class
          IFEND;

        = fsc$estimated_file_size =
          IF device_attribute_p^.estimated_file_size <> rmc$unspecified_file_size THEN
            osp$set_status_abnormal (rmc$resource_management_id, rme$file_size_not_implemented,
                  request_mass_storage, status);
            RETURN; {----->
          IFEND;

        = fsc$initial_volume =
          initial_volume := device_attribute_p^.initial_volume;

        = fsc$mass_storage_class =
          CASE device_attribute_p^.mass_storage_class OF
          = 'A' .. 'Z' =
            mass_storage_class := device_attribute_p^.mass_storage_class;
          = 'a' .. 'z' =
            mass_storage_class := $CHAR ($INTEGER (device_attribute_p^.mass_storage_class) - $INTEGER ('a') +
                  $INTEGER ('A'));
          ELSE
            device_attribute_name := 'MASS_STORAGE_CLASS';
            status.normal := FALSE;
          CASEND;

        = fsc$null_device_attribute =
          ;
        = fsc$removable_media_group =
          IF device_attribute_p^.removable_media_group = osc$null_name THEN
            removable_media_group := osc$null_name;
          ELSE
            clp$validate_name (device_attribute_p^.removable_media_group, removable_media_group, valid_name);
            IF NOT valid_name THEN
              device_attribute_name := 'REMOVABLE_MEDIA_GROUP';
              status.normal := FALSE;
            IFEND;
          IFEND;

        = fsc$requested_transfer_size =
          IF device_attribute_p^.requested_transfer_size > UPPERVALUE (dmt$transfer_size) THEN
            transfer_size := dmc$max_transfer_size;
          ELSEIF (device_attribute_p^.requested_transfer_size >= LOWERVALUE (fst$transfer_size)) AND
                (device_attribute_p^.requested_transfer_size <= UPPERVALUE (fst$transfer_size)) THEN
            transfer_size := device_attribute_p^.requested_transfer_size;
          ELSE
            device_attribute_name := 'REQUESTED_TRANSFER_SIZE';
            status.normal := FALSE;
          IFEND;

        = fsc$shared_queue =
          pfp$convert_shared_queue_to_ord (device_attribute_p^.shared_queue, shared_queue, local_status);
          IF NOT local_status.normal THEN
            device_attribute_name := 'SHARED_QUEUE';
            status.normal := FALSE;
          IFEND;

        = fsc$volume_list =
          volume_list := device_attribute_p^.volume_list;
          IF volume_list <> NIL THEN

          /validate_volume_list/
            BEGIN
              FOR volume_list_index := LOWERBOUND (volume_list^) TO UPPERBOUND (volume_list^) DO
                IF volume_list^ [volume_list_index].recorded_vsn <> rmc$unspecified_vsn THEN
                  rmp$validate_ansi_string (volume_list^ [volume_list_index].
                        recorded_vsn, volume_list^ [volume_list_index].recorded_vsn, status);
                  IF NOT status.normal THEN
                    bap$set_evaluated_file_abnormal (evaluated_file_reference,
                          rme$improper_recorded_vsn_value, request_tape,
                          volume_list^ [volume_list_index].recorded_vsn, status);
                    RETURN; {----->
                  IFEND;
                IFEND;
                IF volume_list^ [volume_list_index].external_vsn <> rmc$unspecified_vsn THEN
                  rmp$validate_ansi_string (volume_list^ [volume_list_index].
                        external_vsn, volume_list^ [volume_list_index].external_vsn, status);
                  IF NOT status.normal THEN
                    bap$set_evaluated_file_abnormal (evaluated_file_reference,
                          rme$improper_external_vsn_value, request_tape,
                          volume_list^ [volume_list_index].external_vsn, status);
                    RETURN; {----->
                  IFEND;
                IFEND;
              FOREND;
            END /validate_volume_list/;
          IFEND;

        = fsc$volume_overflow_allowed =
          volume_overflow_allowed := device_attribute_p^.volume_overflow_allowed;

        ELSE
          bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_file_attrib_key,
                create_file_request, device_attributes_parameter, status);
          osp$append_status_integer (osc$status_parameter_delimiter, device_attribute_index, radix,
                NOT include_radix, status);
          RETURN; {----->
        CASEND;

        IF NOT status.normal THEN
          bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_file_attrib_value,
                create_file_request, device_attributes_parameter, status);
          osp$append_status_parameter (osc$status_parameter_delimiter, device_attribute_name, status);
          RETURN; {----->
        IFEND;
      FOREND;

    PROCEND validate_device_attributes;

?? OLDTITLE ??
?? NEWTITLE := 'PROCEDURE [INLINE] validate_file_attributes', EJECT ??

    PROCEDURE [INLINE] validate_file_attributes
      (    evaluated_file_reference: fst$evaluated_file_reference;
           file_attributes: ^fst$file_attributes;
       VAR file_password: ost$name;
       VAR attachment_logging: boolean;
       VAR status: ost$status);

      CONST
        create_file_request = 'FSP$CREATE_FILE',
        file_attributes_parameter = 'FILE_ATTRIBUTES';

      VAR
        file_attribute_index: integer;

      status.normal := TRUE;

      file_password := osc$null_name;
      attachment_logging := FALSE;

      IF file_attributes = NIL THEN
        RETURN; {----->
      IFEND;

      FOR file_attribute_index := 1 TO UPPERBOUND (file_attributes^) DO
        CASE file_attributes^ [file_attribute_index].selector OF
        = fsc$file_password =
          pfi$convert_password (file_attributes^ [file_attribute_index].file_password, file_password, status);
          IF NOT status.normal THEN
            RETURN; {----->
          IFEND;

        = fsc$attachment_logging =
          IF ((file_attributes^ [file_attribute_index].attachment_logging < LOWERVALUE (boolean)) OR
                (file_attributes^ [file_attribute_index].attachment_logging > UPPERVALUE (boolean))) THEN
            osp$set_status_condition (pfe$bad_log_option, status);
            osp$append_status_integer (osc$status_parameter_delimiter,
                  $INTEGER (file_attributes^ [file_attribute_index].attachment_logging), radix,
                  NOT include_radix, status);
            RETURN; {----->
          ELSE
            attachment_logging := file_attributes^ [file_attribute_index].attachment_logging;
          IFEND;

        = fsc$null_file_attribute =
          ;
        ELSE
          bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_file_attrib_key,
                create_file_request, file_attributes_parameter, status);
          osp$append_status_integer (osc$status_parameter_delimiter, file_attribute_index, radix,
                NOT include_radix, status);
          RETURN; {----->
        CASEND;
      FOREND;

    PROCEND validate_file_attributes;
?? OLDTITLE ??
?? EJECT ??

    status.normal := TRUE;
    osp$verify_system_privilege;

    #CALLER_ID (caller_id);

    IF (fsp$path_element (^evaluated_file_reference, 1) ^ = fsc$local) AND
          evaluated_file_reference.path_handle_info.path_handle_present THEN
      fmp$is_file_attached (evaluated_file_reference.path_handle_info.path_handle, attached, status);
      IF NOT status.normal THEN
        RETURN; {----->
      ELSEIF attached THEN
        evaluated_file_reference.cycle_reference.specification := fsc$next_cycle;
        evaluated_file_reference.path_handle_info.path_handle_present := FALSE;
      IFEND;
    IFEND;

    CASE evaluated_file_reference.cycle_reference.specification OF
    = fsc$low_cycle =
      pf_cycle.cycle_option := pfc$lowest_cycle;
    = fsc$cycle_omitted, fsc$next_cycle, fsc$high_cycle =
      pf_cycle.cycle_option := pfc$highest_cycle;
    = fsc$cycle_number =
      pf_cycle.cycle_option := pfc$specific_cycle;
      pf_cycle.cycle_number := evaluated_file_reference.cycle_reference.cycle_number;
    ELSE
    CASEND;

    validate_cycle_attributes (evaluated_file_reference, cycle_attributes, catalog_cycle_attributes, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    validate_device_attributes (evaluated_file_reference, device_attributes, allocation_size, density,
          device_class, estimated_file_size, initial_volume, mass_storage_class, removable_media_group,
          shared_queue, transfer_size, volume_list, volume_overflow_allowed, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    validate_file_attributes (evaluated_file_reference, file_attributes, file_password, attachment_logging,
          status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    IF device_class = fsc$mass_storage_device THEN
      rmp$build_mass_storage_info (allocation_size, estimated_file_size, initial_volume, mass_storage_class,
            shared_queue, transfer_size, volume_overflow_allowed, caller_id.ring, ^mass_storage_request_info,
            status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;

      IF fsp$path_element (^evaluated_file_reference, 1) ^ = fsc$local THEN
        rmp$validate_mass_storage_info ({family_set_name} osc$null_name, {object_permanent} FALSE,
              pfc$file_object, ^mass_storage_request_info, status);
        IF status.normal THEN
          fmp$request_mass_storage (allocation_size, estimated_file_size, mass_storage_class, initial_volume,
                transfer_size, volume_overflow_allowed, evaluated_file_reference, status);
        IFEND;
      ELSE
        PUSH p_path: [1 .. evaluated_file_reference.number_of_path_elements];
        pfp$convert_fs_to_pft$path (evaluated_file_reference, p_path^);
        pfp$r3_define_mass_storage (p_path^, pf_cycle, file_password, caller_id.ring,
              v$log [attachment_logging], catalog_cycle_attributes, ^mass_storage_request_info, status);
      IFEND;

    ELSEIF device_class = fsc$magnetic_tape_device THEN

      IF volume_list <> NIL THEN
        number_of_volumes := UPPERBOUND (volume_list^) - LOWERBOUND (volume_list^) + 1;
        PUSH p_volume_list: [1 .. number_of_volumes];
        FOR volume_list_index := 1 TO number_of_volumes DO
          p_volume_list^ [volume_list_index].recorded_vsn := volume_list^ [volume_list_index].recorded_vsn;
          p_volume_list^ [volume_list_index].external_vsn := volume_list^ [volume_list_index].external_vsn;
          IF p_volume_list^ [volume_list_index].recorded_vsn = rmc$unspecified_vsn THEN
            p_volume_list^ [volume_list_index].recorded_vsn := p_volume_list^ [volume_list_index].
                  external_vsn;
          ELSEIF volume_list^ [volume_list_index].external_vsn = rmc$unspecified_vsn THEN
            p_volume_list^ [volume_list_index].external_vsn := p_volume_list^ [volume_list_index].
                  recorded_vsn;
          IFEND;
        FOREND;
      ELSE
        PUSH p_volume_list: [1 .. 1];
        p_volume_list^ [1].recorded_vsn := rmc$unspecified_vsn;
        p_volume_list^ [1].external_vsn := rmc$unspecified_vsn;
      IFEND;

      write_ring := rmc$no_write_ring;
      IF attachment_options <> NIL THEN

      /check_for_write/
        FOR attachment_options_index := 1 TO UPPERBOUND (attachment_options^) DO
          IF (attachment_options^ [attachment_options_index].selector = fsc$access_and_share_modes)
{       } AND (attachment_options^ [attachment_options_index].access_modes.selector =
                fsc$specific_access_modes)
{       } AND ((attachment_options^ [attachment_options_index].access_modes.value * write_selections) <>
                $fst$file_access_options []) THEN
            write_ring := rmc$write_ring;
            EXIT /check_for_write/; {----->
          IFEND;
        FOREND /check_for_write/;
      IFEND;

      clp$convert_file_ref_to_string (evaluated_file_reference, {include_open_position} FALSE, path,
            path_size, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;

      bap$fetch_tape_validation (validation_state, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;

      IF validation_state <> bac$no_tape_validation THEN
        tape_validation := validation_state = bac$tape_validation_on;
        rmp$validate_tape_request (tape_validation, path (1, path_size), density, write_ring, p_volume_list^,
              removable_media_group, volume_overflow_allowed, caller_id.ring, file_password,
              attachment_logging, status);
      ELSE
        rmp$complete_tape_request (path (1, path_size), density, write_ring, p_volume_list^,
              removable_media_group, volume_overflow_allowed, caller_id.ring, file_password,
              attachment_logging, status);
      IFEND;
    IFEND;

    IF status.normal THEN
      IF (evaluated_file_reference.cycle_reference.specification = fsc$cycle_omitted) OR
            (evaluated_file_reference.cycle_reference.specification = fsc$next_cycle) THEN
        evaluated_file_reference.cycle_reference.specification := fsc$high_cycle;
      IFEND;
      work_list := $bat$process_pt_work_list [bac$resolve_path, bac$resolve_to_catalog];
      bap$process_pt_request (work_list, osc$null_name, evaluated_file_reference, ignore_pt_results, status);
      IF status.normal THEN
        clp$convert_file_ref_to_string (evaluated_file_reference, {include_open_position} TRUE, resolved_path,
              path_length, status);
        IF status.normal THEN
          clp$convert_string_to_file_ref (resolved_path (1, path_length), parsed_file_reference, status);
          IF status.normal THEN
            resolved_path := parsed_file_reference.path (1, parsed_file_reference.file_path_size);
            path_size := parsed_file_reference.file_path_size + 1;
            resolved_path (path_size) := '.';
            p$add_path_integer (resolved_path, path_size, evaluated_file_reference.cycle_reference.
                  cycle_number);
          IFEND;
        IFEND;
      IFEND;
    IFEND;

  PROCEND bap$create_file;
?? OLDTITLE ??
MODEND bam$create_file;
