;       SCCSID = @(#)d_spinfo.asm	6.1 91/02/15
;       SCCSID = @(#)d_spinfo.asm	1.6 90/02/09
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************

include dos2equ.inc
include api.inc
include basemaca.inc
include error.inc

        EXTRN   __api_begin:near
        EXTRN   __api_end:near
        EXTRN   api_get_extended:far    ; added support for DOSErrorClass
        EXTRN   _api_getvrsn:near
        EXTRN   name_check:far          ; added support for 8.3 filename

LEVEL1                  equ     1       ; passed value for level 1 info
LEVEL1_INFO_SIZE        equ     4       ; bytes needed in FileInfoBuf for info
;/********************** START OF SPECIFICATIONS *********************/
;/*                                                                  */
;/* SUBROUTINE NAME: DosSetPathInfo                                  */
;/*                                                                  */
;/* DESCRIPTIVE NAME: Dos Set Path Information                       */
;/*                                                                  */
;/* FUNCTION: Specifies information for a file or directory          */
;/*                                                                  */
;/*                                                                  */
;/*                                                                  */
;/* NOTES:    Real Mode Only                                         */
;/*           Simulates OS/2 call from DOS 2.x,3.x environment       */
;/*                                                                  */
;/* ENTRY POINT: DosSetPathInfo                                      */
;/*                                                                  */
;/*    LINKAGE: Call Far                                             */
;/*                                                                  */
;/*                                                                  */
;/* INPUT: Stack Frame in form of:                                   */
;/*                                                                  */
;/*  PUSH@  ASCIIZ PathName - file/directory name                    */
;/*  PUSH   WORD   FileInfoLevel - level of file information required*/
;/*  PUSH@  OTHER  FileInfoBuf -  storage area to return file info   */
;/*  PUSH   WORD   FileInfoBufSize - length of FileInfoBuf           */
;/*  PUSH   WORD   PathInfoFlags -  DCR 383                          */
;/*  PUSH   DWORD  Reserved (must be zero)                           */
;/*                                                                  */
;/*                                                                  */
;/* EXIT-NORMAL:   AX = 0                                            */
;/*                                                                  */
;/* EXIT-ERROR:    AX = Errorcode                                    */
;/*       may return error code from Dos 2.x, 3.x, OS/2              */
;/*                                                                  */
;/* EFFECTS:  AX, all other registers preserved                      */
;/*                                                                  */
;/* INTERNAL REFERENCES: none                                        */
;/*                                                                  */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/* EXTERNAL REFERENCES: none                                        */
;/*                                                                  */
;/*    ROUTINES: __api_begin                                         */
;/*              __api_end                                           */
;/*              api_get_extended                                    */
;/*              _api_get_version                                    */
;/*              name_check                                          */
;/*              Int 21h - Get/Set File Date/Time Extended Info      */
;/*                                                                  */
;/*********************** END OF SPECIFICATIONS **********************/


_TEXT   segment byte public 'CODE'

        assume  CS:_TEXT, DS:nothing

        public  DOSSETPATHINFO


PathName        equ     [BP+20]
FileInfoLevel   equ     [BP+18]
FileInfoBuf     equ     [BP+14]
FileInfoBufSize equ     [BP+12]
PathInfoFlags   equ     [BP+10]
Reserved        equ     [BP+6]



DOSSETPATHINFO  proc    far

        call    __api_begin     ; init bp and save bp,ds,bx,cx,dx,si,di,es
                                ; required to save: bp,es,bx,cx,dx,si,di

; check validity of reserved words         cpd12 p2846 11/28/88 KL
        mov     ax,ERROR_INVALID_PARAMETER      ;
        mov     bx,Reserved                     ; reserved words not zeros
        or      bx,bx                           ;
        jnz     qpExit                          ; then return error
        or      bx,Reserved+2                   ;
        jnz     qpExit                          ; then return error
        mov     bx,PathInfoFlags                ; check info flag
        cmp     bx,0                            ; it should be 0 or 010h
        je      st1                             ; cp20 b787888
        cmp     bx,010h
        jnz     qpExit

; check DOS Version
st1:    call    _api_getvrsn    ; get the DOS version
        cmp     ax,0A14h        ;
        jge     version_ok      ; Version >= 10.2
        mov     ax,ERROR_BAD_COMMAND
        jmp     qpExit

version_ok:

; verify the filename in 8.3 range
        mov     ah,1                     ; meta char is valid
        lds     si, [PathName]           ; set up pointer to filename
        call    name_check               ; check name in 8.3 range
        jnc     name_ok                  ; filename is illegal
        jmp     qpExit                   ; Name_check sets the error code
name_ok:
        mov     ax,(D2_GetSetFileDT shl 8) + 03 ; set info
        mov     dx,[FileInfoLevel]       ; Info level 1
        mov     bx,-1                    ; use a path
        lds     si,[PathName]
        les     di,[FileInfoBuf]
        mov     cx,[FileInfoBufSize]
        int     21h
        jc      ErrorExit
        xor     ax,ax
        jmp     short qpExit
ErrorExit:
        call    api_get_extended
qpExit:
        call    __api_end       ; check sigs & restore es,di,si,dx,cx,bx,ds,bp

        ret     18      ; clear stack of entry parameters (bytes)

DOSSETPATHINFO  endp

_TEXT   ends
        end
