Browse Source

+ imdb_records_count()

master
Alex 'AdUser' Z 10 years ago
parent
commit
8329b4ed67
  1. 15
      src/database.c
  2. 8
      src/database.h

15
src/database.c

@ -192,7 +192,20 @@ int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
return processed; return processed;
} }
inline float uint64_t
imdb_records_count(imdb_t * const db) {
struct stat st;
off_t size = 0;
memset(&st, 0x0, sizeof(struct stat));
fstat(db->fd, &st);
size = st.st_size;
return size / IMDB_REC_LEN;
}
float
ratio_from_rec_data(unsigned char * const data) { ratio_from_rec_data(unsigned char * const data) {
uint16_t iw, ih; uint16_t iw, ih;

8
src/database.h

@ -86,6 +86,9 @@ extern int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len);
extern int imdb_open (imdb_t *db, const char *path); extern int imdb_open (imdb_t *db, const char *path);
extern int imdb_close(imdb_t *db); extern int imdb_close(imdb_t *db);
float
ratio_from_rec_data(unsigned char * const data);
/** /**
@returns: @returns:
-1 on error -1 on error
@ -98,4 +101,9 @@ imdb_search(imdb_t * const db,
imdb_search_t * const search, imdb_search_t * const search,
imdb_match_t **matches); imdb_match_t **matches);
/**
@returns: number of records in database
*/
uint64_t
imdb_records_count(imdb_t * const db);
#endif #endif

Loading…
Cancel
Save