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 if (samp_buff_[samp_idx] !=
NULL) {
44 delete samp_buff_[samp_idx];
60 if (new_samp_buff ==
NULL) {
65 memcpy(new_samp_buff, samp_buff_, cnt_ *
sizeof(*samp_buff_));
68 samp_buff_ = new_samp_buff;
70 samp_buff_[cnt_++] = char_samp;
75 bool CharSampSet::LoadCharSamples(FILE *fp) {
81 while (feof(fp) == 0) {
83 if (new_samp !=
NULL) {
84 if (
Add(new_samp) ==
false) {
97 fp = fopen(file_name.c_str(),
"rb");
102 if (fread(&val32, 1,
sizeof(val32), fp) !=
sizeof(val32)) {
106 if (val32 != 0xfefeabd0) {
112 if (samp_set ==
NULL) {
116 if (samp_set->LoadCharSamples(fp) ==
false) {
129 fp = fopen(file_name.c_str(),
"wb");
135 if (fwrite(&val32, 1,
sizeof(val32), fp) !=
sizeof(val32)) {
154 i64_size = fp_in->
Size();
159 if (fp_in->
Read(&val32,
sizeof(val32)) !=
sizeof(val32)) {
162 if (val32 != 0xfefeabd0) {
166 while (fp_in->
eof() ==
false) {
168 i64_pos = fp_in->
Tell();
169 if (new_samp !=
NULL) {
170 bool ret_flag = (enum_obj)->EnumCharSamp(new_samp,
171 (100.0f * i64_pos / i64_size));
173 if (ret_flag ==
false) {
static CharSamp * FromCharDumpFile(CachedFile *fp)
bool Add(CharSamp *char_samp)
static FILE * CreateCharDumpFile(string file_name)
static CharSampSet * FromCharDumpFile(string file_name)
static bool EnumSamples(string file_name, CharSampEnum *enumerator)
int Read(void *read_buff, int bytes)