]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_size.c
40f61906db220fb454eb0361c36254fd451879cf
[netatalk.git] / libatalk / adouble / ad_size.c
1 /*
2  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3  * All rights reserved. See COPYRIGHT.
4  *
5  * if we could depend upon inline functions, this would be one.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <sys/types.h>
15 #include <sys/stat.h>
16 #include <syslog.h>
17
18 #include <atalk/adouble.h>
19
20 off_t ad_size(const struct adouble *ad, const u_int32_t eid)
21 {
22   if (eid == ADEID_DFORK) {
23     struct stat st;
24     
25     if (fstat(ad_dfileno(ad), &st) < 0)
26       return 0;
27     return st.st_size;
28   }  
29
30   return ad_getentrylen(ad, eid);
31