X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Disposition-notification-to: bbelisle AT jpselectronique DOT com Date: Wed, 14 Sep 2005 08:41:11 -0400 From: =?iso-8859-1?Q?Benjamin_B=E9lisle?= Subject: RE: Help with Dos errors In-reply-to: <43280742.sandmann@clio.rice.edu> To: djgpp AT delorie DOT com Message-id: <000201c5b929$9702fbc0$ae7ba8c0@JPS.local> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) Content-type: text/plain; charset=iso-8859-1 Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id j8ECbmoi022091 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Thank you for your responses. My function that writes on the diskette looks a bit like this: if (F_Open ("a:\\agrimtl2.ini", WRITE)) { return 1; } else { EcrireINI (); F_Close (); } sprintf (Buff, "a:\\%u.txt", Annee); Fichier = fopen (Buff, "wb"); if (Fichier == NULL) { return 1; } else { ... And so on so yes I do verify the return values. But I also want to know why it failled, the possible error codes (_doserrno) when writing on (a:) are: ---DOS 3.0+ (INT 24 errors)--- 13h (19) disk write-protected 14h (20) unknown unit 15h (21) drive not ready 16h (22) unknown command 17h (23) data error (CRC) 18h (24) bad request structure length 19h (25) seek error 1Ah (26) unknown media type (non-DOS disk) 1Bh (27) sector not found 1Ch (28) printer out of paper 1Dh (29) write fault 1Eh (30) read fault 1Fh (31) general failure 20h (32) sharing violation 21h (33) lock violation 22h (34) disk change invalid (ES:DI -> media ID structure)(see #01681) 23h (35) FCB unavailable 23h (35) (PTS-DOS 6.51+, S/DOS 1.0+) bad FAT 24h (36) sharing buffer overflow 25h (37) (DOS 4.0+) code page mismatch 26h (38) (DOS 4.0+) cannot complete file operation (EOF / out of input) 27h (39) (DOS 4.0+) insufficient disk space Which is why I do: if(_doserrno > 18 && _doserrno < 40) { DosError = 1; TypeDosError = _doserrno-19; } Then I open a message box displaying the right error message for the user. (Note that I could simply use the strerror(errno) function, but I display the message in different languages, depending on the language setting. What happens (when on the dos computer) is that the function simply aborts without displaying any error message, so _doserrno is not between 18 and 40. The program keeps on running normally. Like I said, this works perfectly when on windows. >DJGPP doesn't use the abort,retry,fail stuff. This is why I don't need to override the int 24 interrupt like the program was done with Borland. I think this may be a problem with the CWSDPMI host and int 21. I've tried the following code to "catch" the error with function 59h of int 21h (Thank you dos bible) which should return the same error codes as _doserrno: regs.h.ah = 0x59; regs.d.ebx = 0; __dpmi_int(0x21, ®s); if(regs.x.ax > 18 && regs.x.ax < 40) { DosError = 1; TypeDosError = regs.x.ax-19; } And again, works fine in Windows (which I've heard has a much better DPMI host than CWSDPMI). Benjamin. -----Message d'origine----- De : Charles Sandmann [mailto:sandmann AT clio DOT rice DOT edu] Envoyé : 14 septembre 2005 07:20 À : djgpp AT delorie DOT com Objet : Re: Help with Dos errors > I want to create a file on a disk (A:) and detect any DOS errors. Errors should always be flagged to the routine which was called. DJGPP doesn't use the abort,retry,fail stuff. > This works fine when I try the program in a Windows XP Dos window, but there > is no error detected (when for example there is no disk) when I try the > program on a DOS Version 6.20 computer with the CWSDPMI host. This may just be the different error code returned; the open or write statements should be checked for failure. You didn't say how it fails under DOS or provide the example code doing the open.