home *** CD-ROM | disk | FTP | other *** search
- FSTREAM(3C) Last changed: 1-7-99
-
-
- NNAAMMEE
- ffssttrreeaamm - iostream and streambuf specialized to files
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ffssttrreeaamm..hh>>
-
- ttyyppeeddeeff lloonngg ssttrreeaammooffff,, ssttrreeaammppooss;;
- ccllaassss iiooss {{
- ppuubblliicc::
- eennuumm sseeeekk__ddiirr {{ bbeegg,, ccuurr,, eenndd }} ;;
- eennuumm ooppeenn__mmooddee {{ iinn,, oouutt,, aattee,, aapppp,, ttrruunncc,, nnooccrreeaattee,, nnoorreeppllaaccee }}
- ;;
- eennuumm iioo__ssttaattee {{ ggooooddbbiitt==00,, eeooffbbiitt,, ffaaiillbbiitt,, bbaaddbbiitt }} ;;
- //// aanndd lloottss ooff ootthheerr ssttuuffff,, sseeee iiooss((33CC)) ......
- }} ;;
-
- ccllaassss iiffssttrreeaamm :: iissttrreeaamm {{
- iiffssttrreeaamm(()) ;;
- ~~iiffssttrreeaamm(()) ;;
- iiffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt ==iiooss::::iinn,,
- iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
- iiffssttrreeaamm((iinntt ffdd)) ;;
- iiffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
-
- vvooiidd aattttaacchh((iinntt ffdd)) ;;
- vvooiidd cclloossee(()) ;;
- vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt ==iiooss::::iinn,,
- iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott)) ;;
- ffiilleebbuuff** rrddbbuuff(()) ;;
- vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
- }};;
-
- ccllaassss ooffssttrreeaamm :: oossttrreeaamm {{
- ooffssttrreeaamm(()) ;;
- ~~ooffssttrreeaamm(()) ;;
- ooffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt ==iiooss::::oouutt,,
- iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
- ooffssttrreeaamm((iinntt ffdd)) ;;
- ooffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
-
- vvooiidd aattttaacchh((iinntt ffdd)) ;;
- vvooiidd cclloossee(()) ;;
- vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt ==iiooss::::oouutt,, iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott))
- ;;
- ffiilleebbuuff** rrddbbuuff(()) ;;
- vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
- }};;
-
- ccllaassss ffssttrreeaamm :: iioossttrreeaamm {{
- ffssttrreeaamm(()) ;;
- ~~ffssttrreeaamm(()) ;;
- ffssttrreeaamm((ccoonnsstt cchhaarr** nnaammee,, iinntt mmooddee,,
- iinntt pprroott ==ffiilleebbuuff::::ooppeennpprroott)) ;;
- ffssttrreeaamm((iinntt ffdd)) ;;
- ffssttrreeaamm((iinntt ffdd,, cchhaarr** pp,, iinntt ll)) ;;
-
- vvooiidd aattttaacchh((iinntt ffdd)) ;;
- vvooiidd cclloossee(()) ;;
- vvooiidd ooppeenn((cchhaarr** nnaammee,, iinntt mmooddee,, iinntt pprroott==ffiilleebbuuff::::ooppeennpprroott)) ;;
- ffiilleebbuuff** rrddbbuuff(()) ;;
- vvooiidd sseettbbuuff((cchhaarr** pp,, iinntt ll)) ;;
- }};;
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- iiffssttrreeaamm, ooffssttrreeaamm, and ffssttrreeaamm specialize iissttrreeaamm, oossttrreeaamm, and
- iioossttrreeaamm, respectively, to files. That is, the associated ssttrreeaammbbuuff
- will be a ffiilleebbuuff.
-
- In the following descriptions, assume that:
-
- * _f is any of iiffssttrreeaamm, ooffssttrreeaamm, or ffssttrreeaamm.
-
- * _p_f_b is a ffiilleebbuuff**.
-
- * _p_s_b is a ssttrreeaammbbuuff**.
-
- * _n_a_m_e and _p_t_r are cchhaarr**s.
-
- * _i, _f_d, _l_e_n, and _p_r_o_t are iinntts.
-
- * _m_o_d_e is an iinntt representing an ooppeenn__mmooddee.
-
- CCoonnssttrruuccttoorrss
- The following constructors are for _xssttrreeaamm, _w_h_e_r_e _x _i_s _e_i_t_h_e_r iiff, ooff,
- _o_r ff:
-
- _xssttrreeaamm(())
- Constructs an unopened _xssttrreeaamm.
-
- _xssttrreeaamm((_n_a_m_e,, _m_o_d_e,, _p_r_o_t))
- Constructs an _xssttrreeaamm _a_n_d _o_p_e_n_s _f_i_l_e _n_a_m_e _u_s_i_n_g _m_o_d_e _a_s _t_h_e
- _o_p_e_n _m_o_d_e _a_n_d _p_r_o_t _a_s _t_h_e _p_r_o_t_e_c_t_i_o_n _m_o_d_e. _B_y _d_e_f_a_u_l_t, _p_r_o_t
- _i_s ffiilleebbuuff::::ooppeennpprroott, _w_h_i_c_h _i_s _0_6_4_4. _T_h_e _e_r_r_o_r _s_t_a_t_e
- (iioo__ssttaattee) _o_f _t_h_e _c_o_n_s_t_r_u_c_t_e_d _xssttrreeaamm _w_i_l_l _i_n_d_i_c_a_t_e _f_a_i_l_u_r_e
- _i_n _c_a_s_e _t_h_e ooppeenn _f_a_i_l_s.
-
- _xssttrreeaamm((_d))
- Constructs an _xssttrreeaamm _c_o_n_n_e_c_t_e_d _t_o _f_i_l_e _d_e_s_c_r_i_p_t_o_r _d, _w_h_i_c_h
- _m_u_s_t _b_e _a_l_r_e_a_d_y _o_p_e_n.
-
- _xssttrreeaamm((_d,,_p_t_r,,_l_e_n))
- Constructs an _xssttrreeaamm _c_o_n_n_e_c_t_e_d _t_o _f_i_l_e _d_e_s_c_r_i_p_t_o_r _d, _a_n_d,
- _i_n _a_d_d_i_t_i_o_n, _i_n_i_t_i_a_l_i_z_e_s _t_h_e _a_s_s_o_c_i_a_t_e_d ffiilleebbuuff _t_o _u_s_e _t_h_e
- _l_e_n _b_y_t_e_s _a_t _p_t_r _a_s _t_h_e _r_e_s_e_r_v_e _a_r_e_a. _I_f _p_t_r _i_s _n_u_l_l _o_r _l_e_n
- _i_s _0, _t_h_e ffiilleebbuuff _w_i_l_l _b_e _u_n_b_u_f_f_e_r_e_d.
-
- MMeemmbbeerr ffuunnccttiioonnss
- _f..aattttaacchh((_d))
- Connects _f to the file descriptor _d. A failure occurs when
- _f is already connected to a file. A failure sets
- iiooss::::ffaaiillbbiitt in _f's error state.
-
- _f..cclloossee(())
- Closes any associated ffiilleebbuuff and thereby breaks the
- connection of the _f to a file. _f's error state is cleared
- except on failure. A failure occurs when the call to
- _f..rrddbbuuff(())-->>cclloossee(()) _f_a_i_l_s.
-
- _f..ooppeenn((_n_a_m_e,,_m_o_d_e,,_p_r_o_t))
- Opens file _n_a_m_e and connects _f to it. If the file does not
- already exist, an attempt is made to create it with
- protection mode _p_r_o_t unless iiooss::::nnooccrreeaattee is set. By
- default, _p_r_o_t is ffiilleebbuuff::::ooppeennpprroott, which is 0644. Failure
- occurs if _f is already open, or the call to _f..rrddbbuuff(())--
- >>ooppeenn(()) _f_a_i_l_s. iiooss::::ffaaiillbbiitt _i_s _s_e_t _i_n _f'_s _e_r_r_o_r _s_t_a_t_u_s _o_n
- _f_a_i_l_u_r_e. _T_h_e _m_e_m_b_e_r_s _o_f ooppeenn__mmooddee _a_r_e _b_i_t_s _t_h_a_t _m_a_y _b_e
- _o_r'_e_d _t_o_g_e_t_h_e_r. (_B_e_c_a_u_s_e _t_h_e _o_r'_i_n_g _r_e_t_u_r_n_s _a_n iinntt, ooppeenn(())
- _t_a_k_e_s _a_n iinntt _r_a_t_h_e_r _t_h_a_n _a_n ooppeenn__mmooddee _a_r_g_u_m_e_n_t.) _T_h_e
- _m_e_a_n_i_n_g_s _o_f _t_h_e_s_e _b_i_t_s _i_n _m_o_d_e _a_r_e:
-
- iiooss::::aapppp
- A seek to the end of file is performed. Subsequent
- data written to the file is always added (appended) at
- the end of file. On some systems this is implemented
- in the operating system. In others it is implemented
- by seeking to the end of the file before each write.
- iiooss::::aapppp implies iiooss::::oouutt.
-
- iiooss::::aattee
- A seek to the end of the file is performed during the
- ooppeenn(()). iiooss::::aattee does not imply iiooss::::oouutt.
-
- iiooss::::iinn
- The file is opened for input. iiooss::::iinn is implied by
- construction and opens of iiffssttrreeaamms. For ffssttrreeaamms it
- indicates that input operations should be allowed if
- possible. Is is legal to include iiooss::::iinn in the modes
- of an oossttrreeaamm in which case it implies that the
- original file (if it exists) should not be truncated.
- If the file being opened for input does not exist, the
- open will fail.
-
- iiooss::::oouutt
- The file is opened for output. iiooss::::oouutt is implied by
- construction and opens of ooffssttrreeaamms. For ffssttrreeaamm it
- says that output operations are to be allowed.
- iiooss::::oouutt may be specified even if _p_r_o_t does not permit
- output.
-
- iiooss::::ttrruunncc
- If the file already exists, its contents will be
- truncated (discarded). This mode is implied when
- iiooss::::oouutt is specified (including implicit specification
- for ooffssttrreeaamm) and neither iiooss::::aattee nor iiooss::::aapppp is
- specified.
-
- iiooss::::nnooccrreeaattee
- If the file does not already exist, the ooppeenn(()) will
- fail.
-
- iiooss::::nnoorreeppllaaccee
- If the file already exists, the ooppeenn(()) will fail. Only
- valid with iiooss::::oouutt.
-
- _p_f_b==_f..rrddbbuuff(())
- Returns a pointer to the ffiilleebbuuff associated with _f.
- ffssttrreeaamm::::rrddbbuuff(()) has the same meaning as iioossttrreeaamm::::rrddbbuuff(())
- but is typed differently.
-
- _f..sseettbbuuff((_p,,_l_e_n))
- Has the usual effect of a sseettbbuuff(()) (see ffiilleebbuuff(3C)),
- offering space for a reserve area or requesting unbuffered
- I/O. Normally the returned _p_s_b is _f..rrddbbuuff(()), _b_u_t _i_t _i_s _0 _o_n
- _f_a_i_l_u_r_e. _A _f_a_i_l_u_r_e _o_c_c_u_r_s _i_f _f _i_s _o_p_e_n _o_r _t_h_e _c_a_l_l _t_o
- _f..rrddbbuuff(())-->>sseettbbuuff _f_a_i_l_s.
-
- SSEEEE AALLSSOO
- ffiilleebbuuff(3C), iissttrreeaamm(3C), iiooss(3C), oossttrreeaamm(3C), ssbbuuff..ppuubb(3C)
-
- This man page is available only online.
-