Subversion Repositories ipe_artfile_utils

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#include <stdlib.h>
2
#include <stdio.h>
3
 
4
#include "utils.h"
5
 
6
size_t file_size(FILE* fp) {
7
        size_t pos = ftell(fp);
8
        fseek(fp, 0, SEEK_END);
9
        size_t len = ftell(fp);
10
        fseek(fp, pos, SEEK_SET);
11
        return len;
12
}
13
 
14
char* sanitize_filename(char* picname) {
15
        // Remove invalid windows characters
16
        // TODO: not yet implemented. not necessary for the regular ART files, though
17
        return picname;
18
}
19
 
20
void* app_zero_alloc(long bytes) {
21
        char* ptr = (char*)malloc(bytes);
22
        int i;
23
        for (i=0; i<bytes; ++i) ptr[i] = 0;
24
        return (void*)ptr;
25
}
26
 
27
unsigned char read_byte(FILE *file) {
28
        int ch = getc(file);
29
        if (ch == EOF)
30
                ch = 0;
31
        return ch;
32
}
33