home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
fileattr.asm
< prev
next >
Wrap
Assembly Source File
|
1990-10-21
|
4KB
|
146 lines
; FILEATTR.ASM
;
; by Ralph Davis
; modified by Rick Spence, Leonard Zerman
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC _FILEATTR
READ_ONLY EQU 1H
HIDDEN EQU 2H
SYSTEM EQU 4H
ARCHIVE EQU 20H
;=========================
;
IN_PARMS STRUC
;
OLD_BP DW ?
RET_ADDR DD ?
FILENAME DD ?
ATTRIBS DD ?
;
IN_PARMS ENDS
;
;==========================
;******************************************
FILEATTR_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:FILEATTR_TEXT
;-------------------------------------------
;
; This procedure turns the requested file attribute
; on or off.
;
; Syntax: CALL fileattr WITH filename,attributes,'+'/'-'
; Return: No return
;
;------------------------
_FILEATTR PROC FAR
PUSH BP
MOV BP,SP
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH SI
PUSH DI
LDS SI,[BP].FILENAME ; Get address of file name passed
PUSH DS
PUSH SI
MOV AH,43H ; Change file mode
MOV AL,0 ; Get current mode
MOV DX,SI
INT 21H
JNC FILE_FOUND
POP SI
POP DS
XOR AX,AX
DEC AX ; Return -1 for error
JMP SHORT EXIT
FILE_FOUND:
LDS SI,[BP].ATTRIBS ; Pick up +\-
CMP BYTE PTR [SI],'+' ; First character must be + or -
JNE FF_2
XOR BX,BX ; Mask for exclusive ORing
JMP SHORT GET_ATTR2
FF_2:
CMP BYTE PTR [SI],'-' ; Not +, is it -?
JE GET_ATTR1 ; First character -,clear attribute
POP SI ; Invalid first character, exit
POP DS
XOR AX,AX
DEC AX ; Return -1 for error
JMP SHORT EXIT
GET_ATTR1:
MOV BX,0FFFFH ; Mask for exclusive ORing
GET_ATTR2:
INC SI ; Point to next character
MOV AL,[SI]
OR AL,AL
JZ CHANGE_IT
CMP AL,'+'
JNE IS_IT_MINUS
XOR BX,BX ; Set up mask for exclusive ORing
JMP SHORT GET_ATTR2
IS_IT_MINUS:
CMP AL,'-'
JNE IS_ARCHIVE
MOV BX,0FFFFH
JMP SHORT GET_ATTR2
AND AL,0DFH ; Force to capital letter
IS_ARCHIVE:
AND AL,0DFH ; Convert to upper-case
CMP AL,'A' ; Archive?
JNE IS_HIDDEN ; No
MOV DX,ARCHIVE ; Pick up mask
JMP SHORT SET_ATTR
IS_HIDDEN:
CMP AL,'H' ; Hidden?
JNE IS_RDONLY ; No
MOV DX,HIDDEN ; Pick up mask
JMP SHORT SET_ATTR
IS_RDONLY:
CMP AL,'R' ; Read only?
JNE IS_SYSTEM ; No
MOV DX,READ_ONLY ; Pick up mask
JMP SHORT SET_ATTR
IS_SYSTEM:
CMP AL,'S' ; System?
JNE GET_ATTR2 ; No, invalid character
MOV DX,SYSTEM ; Pick up mask
SET_ATTR:
XOR DX,BX ; Turn attribute bit on or off
TEST BX,0FFFFH ; Are we turning bit on or off?
JNZ CLEAR_ATTR ; All FFFFs means turn it off
OR CX,DX ; Set attribute bit
JMP SHORT GET_ATTR2
CLEAR_ATTR:
AND CX,DX ; Clear attribute bit
JMP SHORT GET_ATTR2
CHANGE_IT:
POP DX ; Retrieve address of filename
POP DS
MOV AH,43H ; Change mode
MOV AL,1 ; Set attribute
INT 21H
XOR AX,AX ; Return 0 for successful completion
EXIT: POP DI
POP SI
POP DS
POP DX
POP CX
POP BX
POP BP
RET
_FILEATTR ENDP
;----------------------------------------
FILEATTR_TEXT ENDS
;*******************************************************
END