home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20368 < prev    next >
Encoding:
Internet Message Format  |  1992-12-29  |  2.1 KB

  1. Path: sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!<UNAUTHENTICATED>+
  2. From: Barry_Wolman@transarc.com
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Getting Size of Large Files
  5. Message-ID: <ofDwLZCSMUI3IEX0Ef@transarc.com>
  6. Date: 28 Dec 92 17:28:37 GMT
  7. Article-I.D.: transarc.ofDwLZCSMUI3IEX0Ef
  8. Organization: Carnegie Mellon, Pittsburgh, PA
  9. Lines: 57
  10.  
  11. I'm trying to track down a problem in my SerialPrint II DA.  SP II
  12. prints TEXT files on serial printers using the text fonts defined in
  13. the printers.  The process is quite simple:  open appropriate serial
  14. port, open the file specified by user, loop reading lines from file
  15. and sending lines to serial port.
  16.     
  17. Recently a user reported a problem printing "large" files.  When I
  18. investigated, I found that files smaller than 65536 were handled
  19. properly.  Files 65536 characters or larger _always_ got an error -51
  20. (bad iorefNum) in the code that determines the size of the file by
  21. calling PBGetEOF.  I reviewed the code and checked Think Reference; I
  22. can't understand why the code works for small files and fails for
  23. large ones.  I'd check Inside Mac, but I'm still unpacking from my
  24. recent move and my copies of IM haven't surfaced yet.
  25.  
  26. I'd appreciate hearing from anyone who can help me with this problem.
  27. My code is appended to this message.
  28.  
  29. Thanks,
  30. Barry
  31.  
  32. --------------------
  33.  
  34. ffopen ()
  35. {
  36.     static    SFReply frommac;
  37.     register ParmBlkPtr pb;
  38.     OSErr iErr;
  39.  
  40.     pb = &filepb;
  41.     
  42.     SFGetFile (where, 0L, 0L, 1, mytypelist, 0L, &frommac);
  43.     if (frommac.good) {
  44.         pb->ioParam.ioNamePtr = frommac.fName;
  45.         pb->ioParam.ioCompletion = nil;
  46.         pb->ioParam.ioVersNum = 0;
  47.         pb->ioParam.ioMisc = _iobuf;
  48.         pb->ioParam.ioVRefNum = frommac.vRefNum;
  49.         pb->ioParam.ioPermssn = fsRdPerm;
  50.         pb->ioParam.ioPosMode = 3456;
  51.         PBOpen(pb,FALSE);
  52.         if(pb->ioParam.ioResult) {
  53.             show_error(SFGET_ALERT,pb->ioParam.ioResult);
  54.             return (FALSE);
  55.         }
  56.         else {
  57.             if ((iErr = PBGetEOF(pb,0)) != noErr) {
  58.                 show_error(GETEOF_ALERT,iErr);
  59.                 return (FALSE);
  60.             }
  61.  
  62.             filelength = (long)(pb->ioParam.ioMisc);
  63.             return (TRUE);
  64.         }
  65.     }
  66.     else return (FALSE);
  67. }
  68.