Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows Win32 STL file
can anyone explain the advantages\disadvanteges of each method?
when would i want to use each? (assuming i'm working on windows of course)
Posted 10-Mar-10 0:55am
henitba125
Edited 10-Mar-10 0:56am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

fstream is a C++ object. It will work in any OS.
Win32 APIs will work only in Windows.
 
fstream implementation in Windows will eventually call the Win32 APIs.
 
So the first approach will give you portability.
The second approach will execute slightly faster.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

They have two different philosophy with a certain area of overlap.
 
fstream implements the "concept" of C++ stream when the data flow are directed to files.
It does so by cooperating with a number of other classes like strembuff and locales, whose defaults do almost nothing, but you can replace in modular way.
 
Win32 API are the surface of the "iron" that the operating system drives.
They provide their own a number of "features", many of them are used internally by the fstream implementation, some are almost transparently (apart some name changes) re-exposed at the C++ level, some other are left unused.
 
Consider also that many of the API are not even "windows" but "file system" related and can have limited functionality on certain file system respect to other (FAT has less attributes than NTFS, for example)
 
So, if you have to manage file system related attributes probably the native API are more suitable (C++ models are not interested in that), if you have to control the way data are written/read fstream is probably much suitable.
 
Consider also that -even if fstreams can be binary- they are naturally text oriented converters, while native API are binary oriented bulk movers.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

thanks a lot, so there isn't much diffrence when developing for windows.
or are there any limitations using any method? such as security options available on one but not on the other, or limitations on file size? are ther opertions that are very easy to implement using one way, but are much more difficult in the other? is the best practice for developing on windows to use the win32 api?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I can find the same terms (for example: HANDLE) by reading of
- a WIN32 API documentation
- a Task Manager report
 
Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 337
1 DamithSL 305
2 ridoy 264
3 OriginalGriff 208
4 George Jonsson 140
0 OriginalGriff 7,968
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,524
3 Maciej Los 5,438
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 12 Mar 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100