* _PRFILE
* PRFILE opcode recursive code
* Copyright (c) 2005 Ladybridge Systems, All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 
* Ladybridge Systems can be contacted via the www.openqm.com web site.
* 
* START-HISTORY:
* 30 Aug 05  2.2-9 Only uppercase pathname on Windows.
* 16 Sep 04  2.0-1 OpenQM launch. Earlier history details suppressed.
* END-HISTORY
*
* START-DESCRIPTION:
*
*    subroutine prfile(file, record, pathname, status.code)
*
*    file        = VOC name of directory file to receive record
*    record      = Record name (It will be deleted if it exists)
*    pathname    = DOS pathname of record
*    status.code = 0   : Success
*                  -ve : Take ON ERROR clause
*                  +ve : Take ELSE clause
*
* END-DESCRIPTION
*
* START-CODE

$internal
$no.symbols
$no.xref
$recursive

subroutine prfile(file, recd, pathname, status.code)

$include syscom err.h
$include syscom keys.h
$include int$keys.h

   pathname = ""
   status.code = 0

   if recd = '' then
      if file = '$HOLD' then return
      if file = '' then return
   end

   record = ospath(recd, os$mapped.name)

   open file to f else
      open upcase(file) to f else
         status.code = 1           ;* File not found. STATUS() set by OPEN
         return
      end
      file = upcase(file)     
   end

   if fileinfo(f, fl$type) = fl$type.dir then
      recordlocku f, record
      delete f, record
      pathname = fileinfo(f, fl$path) : @ds : record
      if system(91) then pathname = upcase(pathname)
      status.code = 0
   end else                        ;* Not a directory file
      set.status er$ndir
      status.code = 1
   end

   return
end

* END-CODE
