Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #850 > unrolled thread
| Started by | kerravon@w3.to |
|---|---|
| First post | 2013-03-09 23:00 -0800 |
| Last post | 2013-03-11 03:53 -0400 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.os.msdos.programmer
create new file kerravon@w3.to - 2013-03-09 23:00 -0800
Re: create new file kerravon@w3.to - 2013-03-09 23:48 -0800
Re: create new file "R.Wieser" <address@not.available> - 2013-03-10 16:44 +0100
Re: create new file "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-03-11 03:53 -0400
| From | kerravon@w3.to |
|---|---|
| Date | 2013-03-09 23:00 -0800 |
| Subject | create new file |
| Message-ID | <75580a0d-15e3-41da-9e90-0d4f70d16e83@googlegroups.com> |
I have the following program:
C:\devel\pdos\src>type writfil.c
#include <stdio.h>
int main(void)
{
FILE *fq;
printf("opening file\n");
fq = fopen("zzout.txt", "w");
printf("fq is %p\n", fq);
return (0);
}
And I compiled it with tcc++ 1.01 and then
ran it under my own OS (PDOS) and was
surprised to see that after printing
"opening file" there was an MSDOS
INT 21h ah=3d call.
I was expecting ah=3c
http://www.ctyme.com/intr/int-21.htm
Is it normal for a C runtime to treat an
fopen of "w" as "check to see if there is
an existing file before creating one? I
would have expected that MSDOS took care
of that, no need for the C runtime library
to care.
Thanks. Paul.
[toc] | [next] | [standalone]
| From | kerravon@w3.to |
|---|---|
| Date | 2013-03-09 23:48 -0800 |
| Message-ID | <ef7511d8-dd9c-4b11-801d-1181c822bf05@googlegroups.com> |
| In reply to | #850 |
On Sunday, March 10, 2013 6:00:38 PM UTC+11, kerr...@w3.to wrote: > > I was expecting ah=3c A bit more information. There is a AH=43h call first (get file attributes), and once I changed PDOS to return a failure on that call, I did get a 3C call. BFN. Paul.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2013-03-10 16:44 +0100 |
| Message-ID | <513caa5c$0$6873$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #851 |
Hello Paul, Its quite possible the C library does some extra/extensive checking on that filename. Possible reason ? That function can most likely be used to open a few things more than just a disk-file. Console in and output as well as RS232 comes to mind. Depending on what you open diferent subsequent actions need to be taken. You could tell your compiler to generate (an intermediate) Assembler-file too, and see what it does after the (trying to) open the existing file (int 21h, AH=3Dh). Regards, Rudy Wieser -- Origional message <kerravon@w3.to> schreef in berichtnieuws ef7511d8-dd9c-4b11-801d-1181c822bf05@googlegroups.com... > On Sunday, March 10, 2013 6:00:38 PM UTC+11, kerr...@w3.to wrote: > > > > > I was expecting ah=3c > > A bit more information. There is a AH=43h call > first (get file attributes), and once I changed > PDOS to return a failure on that call, I did > get a 3C call. > > BFN. Paul. >
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <do_not_have@notemailnotq.cpm> |
|---|---|
| Date | 2013-03-11 03:53 -0400 |
| Message-ID | <khk2dd$rbr$1@speranza.aioe.org> |
| In reply to | #850 |
<kerravon@w3.to> wrote in message news:75580a0d-15e3-41da-9e90-0d4f70d16e83@googlegroups.com... > Is it normal for a C runtime to treat an > fopen of "w" as "check to see if there is > an existing file before creating one? According to Harbison and Steele's "C: A Reference Manual", 3rd edition, "w" is supposed to either create a new file or truncate an existing file. "w+" truncates too. "wb" is not listed. ISO C99 says "w+" is to "truncate to zero length or create text file for update" in 7.19.5.3 "The fopen function" subsection 3. "w", "w+", and "wb" all truncate. ISTM, that the "truncation" feature of "w", "wb", and "w+", would imply "w" is supposed to check the existence of the file in order to delete it if it exists, i.e., "truncate"... So, I'd say: "Yes." Although, I've not actually tested any C libraries to check what they actually do for this situation. FYI, current ISO C "rough draft" specifications are available online. And, there is comp.lang.c if you dare go there... Rod Pemberton
[toc] | [prev] | [standalone]
Back to top | Article view | comp.os.msdos.programmer
csiph-web