38 void CharSampSet::Cleanup() {
39 if (samp_buff_ != NULL) {
41 if (own_samples_ ==
true) {
42 for (
int samp_idx = 0; samp_idx < cnt_; samp_idx++) {
43 delete samp_buff_[samp_idx];
60 memcpy(new_samp_buff, samp_buff_, cnt_ *
sizeof(*samp_buff_));
63 samp_buff_ = new_samp_buff;
65 samp_buff_[cnt_++] = char_samp;
70 bool CharSampSet::LoadCharSamples(FILE *fp) {
76 while (feof(fp) == 0) {
78 if (new_samp != NULL) {
79 if (
Add(new_samp) ==
false) {
92 fp = fopen(file_name.c_str(),
"rb");
97 if (fread(&val32, 1,
sizeof(val32), fp) !=
sizeof(val32)) {
101 if (val32 != 0xfefeabd0) {
107 if (samp_set->LoadCharSamples(fp) ==
false) {
120 fp = fopen(file_name.c_str(),
"wb");
126 if (fwrite(&val32, 1,
sizeof(val32), fp) !=
sizeof(val32)) {
142 i64_size = fp_in->
Size();
147 if (fp_in->
Read(&val32,
sizeof(val32)) !=
sizeof(val32)) {
150 if (val32 != 0xfefeabd0) {
154 while (fp_in->
eof() ==
false) {
156 i64_pos = fp_in->
Tell();
157 if (new_samp != NULL) {
158 bool ret_flag = (enum_obj)->EnumCharSamp(new_samp,
159 (100.0f * i64_pos / i64_size));
161 if (ret_flag ==
false) {
static CharSampSet * FromCharDumpFile(string file_name)
static FILE * CreateCharDumpFile(string file_name)
static CharSamp * FromCharDumpFile(CachedFile *fp)
static bool EnumSamples(string file_name, CharSampEnum *enumerator)
int Read(void *read_buff, int bytes)
bool Add(CharSamp *char_samp)