1
0
Fork 0
forked from len0rd/rockbox

Changed Miika's open() and write() to fopen() and fwrite() the old way was causing some troubles with filepermissions. Please test on linux, and check if the file has normal permissions.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6401 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomas Salfischberger 2005-05-02 23:50:43 +00:00
parent 84364bc4ff
commit 6875417fe2

View file

@ -46,15 +46,14 @@ long long_to_big_endian (void* value)
int main() int main()
{ {
FILE *in; FILE *in, *idx_out, *desc_out;
int idx_out, desc_out;
struct word w; struct word w;
char buf[10000]; char buf[10000];
long cur_offset = 0; long cur_offset = 0;
in = fopen("dict.preparsed", "r"); in = fopen("dict.preparsed", "r");
idx_out = open("dict.index", O_WRONLY | O_CREAT); idx_out = fopen("dict.index", "wb");
desc_out = open("dict.desc", O_WRONLY | O_CREAT); desc_out = fopen("dict.desc", "wb");
if (in == NULL || idx_out < 0 || desc_out < 0) if (in == NULL || idx_out < 0 || desc_out < 0)
{ {
@ -79,20 +78,20 @@ int main()
/* We will null-terminate the words */ /* We will null-terminate the words */
strncpy(w.word, word, WORDLEN - 1); strncpy(w.word, word, WORDLEN - 1);
w.offset = long_to_big_endian(&cur_offset); w.offset = long_to_big_endian(&cur_offset);
write(idx_out, &w, sizeof(struct word)); fwrite(&w, sizeof(struct word), 1, idx_out);
while (1) while (1)
{ {
int len = strlen(desc); int len = strlen(desc);
cur_offset += len; cur_offset += len;
write(desc_out, desc, len); fwrite(desc, len, 1, desc_out);
desc = strtok(NULL, "\t"); desc = strtok(NULL, "\t");
if (desc == NULL) if (desc == NULL)
break ; break ;
cur_offset++; cur_offset++;
write(desc_out, "\n", 1); fwrite("\n", 1, 1, desc_out);
} }
} }