home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
CDTools
/
IDer
/
Routines
/
GetFileData.s
< prev
next >
Wrap
Text File
|
1997-02-18
|
1KB
|
57 lines
Move.W #FILEOPENERR,_ErrorCode
Move.L _FileName(PC),D1
Move.L #MODE_OLDFILE,D2
CALL Open,DOS ;make sure the file actually exists
Move.L D0,_FileHandle
Beq LaunchDone
Move.W #FILEREADERR,_ErrorCode
Move.L _FileHandle(PC),D1
Move.L _FileData(PC),D2
Move.L #IDData,D3 ;read in 2k of the file for Id'ing
CALL Read
Tst.L D0
Beq LaunchDone
Move.L _FileHandle(PC),D1
Moveq #0,D2
Moveq #OFFSET_BEGINNING,D3
CALL Seek
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Tst.B _Crunched
Bne.S .LoadedOk
Move.L FileData,D0
Cmp.L #'PP20',D0
Beq.S .IsCrunched
Cmp.L #'XPKF',D0
Bne.S .LoadedOk
.IsCrunched
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Tst.L _XPKBase
Bne.S .GotXPKLib
Lea XPKLibrary(PC),A1
Moveq #0,D0
CALL OpenLibrary,EXEC
Move.L D0,_XPKBase
Beq.S .LoadedOk
.GotXPKLib Move.L _FileHandle(PC),_XPKTags+4 ;for crunched files
Move.W #XPKERROR,_ErrorCode
Lea _XPKTags(PC),A0
CALL XpkUnpack,XPK
Tst.L D0
Bne LaunchDone
Move.L _OutputBuffer(PC),_FileData
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
.LoadedOk Move.L _FileHandle(PC),D1
CALL Close,DOS
Clr.L _FileHandle ;cleanup
Clr.W _ErrorCode