comparison src/ls-hdf5.h @ 6760:301885c9d265

[project @ 2007-06-27 02:27:51 by dbateman]
author dbateman
date Wed, 27 Jun 2007 02:27:51 +0000
parents 768d3ad80bbf
children 93c65f2a5668
comparison
equal deleted inserted replaced
6759:dd8cef76043d 6760:301885c9d265
41 41
42 // keep track of current item index in the file 42 // keep track of current item index in the file
43 int current_item; 43 int current_item;
44 44
45 hdf5_fstreambase () { file_id = -1; } 45 hdf5_fstreambase () { file_id = -1; }
46
47 ~hdf5_fstreambase () { close (); }
46 48
47 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0) 49 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0)
48 { 50 {
49 if (mode & std::ios::in) 51 if (mode & std::ios::in)
50 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); 52 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
51 else if (mode & std::ios::out) 53 else if (mode & std::ios::out)
52 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 54 {
53 55 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
56 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
57 else
58 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
59 H5P_DEFAULT);
60 }
54 if (file_id < 0) 61 if (file_id < 0)
55 std::ios::setstate (std::ios::badbit); 62 std::ios::setstate (std::ios::badbit);
56 63
57 current_item = 0; 64 current_item = 0;
58 } 65 }
72 clear (); 79 clear ();
73 80
74 if (mode & std::ios::in) 81 if (mode & std::ios::in)
75 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); 82 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
76 else if (mode & std::ios::out) 83 else if (mode & std::ios::out)
77 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 84 {
78 85 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
86 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
87 else
88 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
89 H5P_DEFAULT);
90 }
79 if (file_id < 0) 91 if (file_id < 0)
80 std::ios::setstate (std::ios::badbit); 92 std::ios::setstate (std::ios::badbit);
81 93
82 current_item = 0; 94 current_item = 0;
83 } 95 }