stevec@Apple.COM (Steve Christensen) (04/16/91)
BRBOYER%MTUS5.BITNET (Bradley R. Boyer) writes: > I have been developing with Consulair Assembly language. I just recently >ran into a brief snag that I hope that someone can help me with. I am using >_GetVol to retrieve the vRefNum of my current volume. I am bot quite sure >what I am getting back, but it is not a valid refnum as far as the file >managers _Read is concerned. I think you're confusing file refNums and volume refNums. GetVol will return a working directory reference number or a volume reference number, depending on what the last call to SetVol did. To read from a file, you'd need to do the following setup (assuming a stack frame pointed to by A6): ... LEA pb(A6),A0 ; point to the parameter block _HGetVol ; get the current vRefNum (or WDRefNum) BNE Error ; -> no default volume ; ioVRefNum(A0) now contains a vRefNum or WDRefNum LEA filename,A1 ; point to the filename whereever it is MOVE.L A1,ioNamePtr(A0) MOVE.B #fsCurPerm,ioPermssn(A0); access permission CLR.L ioMisc(A0) ; let FS allocate file access buffer CLR.L ioDirID(A0) ; just use the vRefNum _HOpen ; try to open the file BNE Error ; -> couldn't do it ; ioRefNum(A0) now contains the file's refNum LEA buffer,A1 ; point to the read buffer MOVE.L A1,ioBuffer(A0) MOVE.L #byteCount,ioReqCount(A0) ; how many bytes to read MOVE.W #fsFromStart,ioPosMode(A0); start reading from the beginning MOVE.L #offset,ioPosOffset(A0) ; this many bytes from the beginning _Read ; read some bytes BNE Error That's all there is to it... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen Never hit a man with glasses. stevec@apple.com Hit him with a baseball bat.