]> arthur.barton.de Git - netatalk.git/blob - libatalk/adouble/ad_size.c
Initial revision
[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 #include <stdio.h>
9 #include <unistd.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <syslog.h>
13
14 #include <atalk/adouble.h>
15
16 off_t ad_size(const struct adouble *ad, const u_int32_t eid)
17 {
18   if (eid == ADEID_DFORK) {
19     struct stat st;
20     
21     if (fstat(ad_dfileno(ad), &st) < 0)
22       return 0;
23     return st.st_size;
24   }  
25
26   return ad_getentrylen(ad, eid);
27