?? RIGHT := 110 ??
MODULE fsm$resolve_file_reference;
?? NEWTITLE := 'NOS/VE : File System', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc fst$file_reference
*copyc fst$goi_object_information
*copyc fst$path
*copyc oss$job_paged_literal
*copyc ost$status
?? POP ??
*copyc clp$convert_file_ref_to_string
*copyc clp$evaluate_file_reference
*copyc clp$trimmed_string_size
*copyc pfp$r3_get_object_information

?? NEWTITLE := 'fsp$resolve_file_reference', EJECT ??
  PROCEDURE [XDCL, #GATE] fsp$resolve_file_reference
    (    file_reference: fst$file_reference;
     VAR resolved_file_reference: fst$path;
     VAR resolved_file_reference_size: fst$path_size;
     VAR status: ost$status);

    VAR
      resolved_cycle_request: [READ, oss$job_paged_literal] fst$goi_information_request :=
            [[fsc$specific_depth, 1], [fsc$goi_cycle_identity]];

    VAR
      evaluated_file_reference: fst$evaluated_file_reference,
      information_request: fst$goi_information_request,
      object_info_sequence: ^SEQ ( * ),
      object_info_sequence_size: ost$positive_integers,
      object_information: ^fst$goi_object_information;

    clp$evaluate_file_reference (file_reference, $clt$file_ref_parsing_options [],
         {resolve_cycle_number} TRUE, evaluated_file_reference, status);
    IF status.normal THEN
      IF evaluated_file_reference.cycle_reference.specification = fsc$cycle_omitted THEN
        information_request := resolved_cycle_request;
        object_info_sequence_size := #SIZE (fst$goi_object_information) + fsc$max_path_size +
              #SIZE (fst$goi_object);
        PUSH object_info_sequence: [[REP object_info_sequence_size OF cell]];
        pfp$r3_get_object_information (evaluated_file_reference, information_request, NIL,
              object_info_sequence, status);
        IF status.normal THEN
          RESET object_info_sequence;
          NEXT object_information IN object_info_sequence;
          resolved_file_reference := object_information^.resolved_path^;
          resolved_file_reference_size := clp$trimmed_string_size (resolved_file_reference);
        IFEND;
      ELSE
        clp$convert_file_ref_to_string (evaluated_file_reference, {include_open_position} FALSE,
              resolved_file_reference, resolved_file_reference_size, status);
      IFEND;
    IFEND;

  PROCEND fsp$resolve_file_reference;
MODEND fsm$resolve_file_reference;
