PDA

View Full Version : fopen vs open



rotis23
12-10-2002, 05:13 AM
i did have a search for this.

i understand open is a low-level version of fopen and allows greater control over devices. file permissions can also be set on the same line.

what are the pros of using fopen over open? i need to be able to set permissions. what is the best way of doing this with fopen?

some stuff on the web discussed the problems of using many fopens at once. also that using open may cause performance problems.

TIA, rotis23.

Hammer
12-10-2002, 05:14 AM
>>i need to be able to set permissions. what is the best way of doing this with fopen?
You can't, I don't believe.

Is this *nix specific, if so, I'll move it to the other board.

rotis23
12-10-2002, 05:29 AM
yeah, i'm using open at the moment. i just wasn't sure of the practical differences.

i think this is relevent to both. maybe more useful in the linux prog board.

rotis23
12-10-2002, 05:46 AM
ok, thanks for the correction.

i wasn't aware that open was posix specific. my question has been answered.

damonbrinkley
12-10-2002, 07:12 AM
fopen() doesn't deal with permissions, you need to use the chmod() system call for that if you're under Linux.

moi
12-10-2002, 02:30 PM
for those who may be interested and not know, open() also allows lower-level file control under ms-dawz, but i'd imagine in different ways than a posix version.