home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!<UNAUTHENTICATED>+
- From: Barry_Wolman@transarc.com
- Newsgroups: comp.sys.mac.programmer
- Subject: Getting Size of Large Files
- Message-ID: <ofDwLZCSMUI3IEX0Ef@transarc.com>
- Date: 28 Dec 92 17:28:37 GMT
- Article-I.D.: transarc.ofDwLZCSMUI3IEX0Ef
- Organization: Carnegie Mellon, Pittsburgh, PA
- Lines: 57
-
- I'm trying to track down a problem in my SerialPrint II DA. SP II
- prints TEXT files on serial printers using the text fonts defined in
- the printers. The process is quite simple: open appropriate serial
- port, open the file specified by user, loop reading lines from file
- and sending lines to serial port.
-
- Recently a user reported a problem printing "large" files. When I
- investigated, I found that files smaller than 65536 were handled
- properly. Files 65536 characters or larger _always_ got an error -51
- (bad iorefNum) in the code that determines the size of the file by
- calling PBGetEOF. I reviewed the code and checked Think Reference; I
- can't understand why the code works for small files and fails for
- large ones. I'd check Inside Mac, but I'm still unpacking from my
- recent move and my copies of IM haven't surfaced yet.
-
- I'd appreciate hearing from anyone who can help me with this problem.
- My code is appended to this message.
-
- Thanks,
- Barry
-
- --------------------
-
- ffopen ()
- {
- static SFReply frommac;
- register ParmBlkPtr pb;
- OSErr iErr;
-
- pb = &filepb;
-
- SFGetFile (where, 0L, 0L, 1, mytypelist, 0L, &frommac);
- if (frommac.good) {
- pb->ioParam.ioNamePtr = frommac.fName;
- pb->ioParam.ioCompletion = nil;
- pb->ioParam.ioVersNum = 0;
- pb->ioParam.ioMisc = _iobuf;
- pb->ioParam.ioVRefNum = frommac.vRefNum;
- pb->ioParam.ioPermssn = fsRdPerm;
- pb->ioParam.ioPosMode = 3456;
- PBOpen(pb,FALSE);
- if(pb->ioParam.ioResult) {
- show_error(SFGET_ALERT,pb->ioParam.ioResult);
- return (FALSE);
- }
- else {
- if ((iErr = PBGetEOF(pb,0)) != noErr) {
- show_error(GETEOF_ALERT,iErr);
- return (FALSE);
- }
-
- filelength = (long)(pb->ioParam.ioMisc);
- return (TRUE);
- }
- }
- else return (FALSE);
- }
-