-#ifdef USE_MMAPPED_HEADERS
- if (eid != ADEID_RFORK) {
- memcpy(buf, ad->ad_data + cc, buflen);
- cc = buflen;
- goto ad_read_done;
- }
-#endif
- if ( ad->ad_hf.adf_off != cc ) {
- if ( lseek( ad->ad_hf.adf_fd, (off_t) cc, SEEK_SET ) < 0 ) {
- return( -1 );
- }
- ad->ad_hf.adf_off = cc;
- }
-
- if (( cc = read( ad->ad_hf.adf_fd, buf, buflen )) < 0 ) {
- return( -1 );
- }
-
-#ifndef USE_MMAPPED_HEADERS
- /*
- * We've just read in bytes from the disk that we read earlier
- * into ad_data. If we're going to write this buffer out later,
- * we need to update ad_data.
- */
- if (ad->ad_hf.adf_off < ad_getentryoff(ad, ADEID_RFORK)) {
- if ( ad->ad_hf.adf_flags & O_RDWR ) {
- memcpy(buf, ad->ad_data + ad->ad_hf.adf_off,
- MIN(sizeof( ad->ad_data ) - ad->ad_hf.adf_off, cc));
- } else {
- memcpy(ad->ad_data + ad->ad_hf.adf_off, buf,
- MIN(sizeof( ad->ad_data ) - ad->ad_hf.adf_off, cc));
- }
- }
- ad->ad_hf.adf_off += cc;
-#else
-ad_read_done:
-#endif
+ if ( ad_reso_fileno( ad ) == -1 ) {
+ /* resource fork is not open ( cf etc/afp/fork.c) */
+ return 0;
+ }
+ r_off = ad_getentryoff(ad, eid) + off;
+
+ if (( cc = adf_pread( &ad->ad_resource_fork, buf, buflen, r_off )) < 0 ) {
+ return( -1 );
+ }
+ /*
+ * We've just read in bytes from the disk that we read earlier
+ * into ad_data. If we're going to write this buffer out later,
+ * we need to update ad_data.
+ * FIXME : always false?
+ */
+ if (r_off < ad_getentryoff(ad, ADEID_RFORK)) {
+ if ( ad->ad_resource_fork.adf_flags & O_RDWR ) {
+ memcpy(buf, ad->ad_data + r_off,
+ MIN(sizeof( ad->ad_data ) - r_off, cc));
+ } else {
+ memcpy(ad->ad_data + r_off, buf,
+ MIN(sizeof( ad->ad_data ) - r_off, cc));
+ }
+ }