mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-06 18:00:24 +08:00
Revert a stale change included in the merge.
This commit is contained in:
parent
99be33303a
commit
c2ff9f01a6
@ -150,13 +150,6 @@ static int
|
||||
readfile(const NCURI* uri, const char* suffix, NCbytes* packet)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
|
||||
char buf[1024];
|
||||
int fd = -1;
|
||||
int flags = 0;
|
||||
off_t filesize = 0;
|
||||
d4size_t totalread = 0;
|
||||
|
||||
NCbytes* tmp = ncbytesnew();
|
||||
char* filename = NULL;
|
||||
|
||||
@ -166,48 +159,6 @@ readfile(const NCURI* uri, const char* suffix, NCbytes* packet)
|
||||
filename = ncbytesextract(tmp);
|
||||
ncbytesfree(tmp);
|
||||
|
||||
flags = O_RDONLY;
|
||||
#ifdef O_BINARY
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
fprintf(stderr,"XXX: flags=0x%x file=%s\n",flags,filename);
|
||||
fd = NCopen2(filename,flags);
|
||||
if(fd < 0) {
|
||||
nclog(NCLOGERR,"open failed:%s",filename);
|
||||
fprintf(stderr,"XXX: open failed: flags=0x%x file=%s\n",flags,filename);
|
||||
fflush(stderr);
|
||||
stat = NC_ENOTFOUND;
|
||||
goto done;
|
||||
}
|
||||
/* Get the file size */
|
||||
filesize = lseek(fd,(d4size_t)0,SEEK_END);
|
||||
if(filesize < 0) {
|
||||
stat = NC_EIO;
|
||||
nclog(NCLOGERR,"lseek failed: %s",filename);
|
||||
goto done;
|
||||
}
|
||||
/* Move file pointer back to the beginning of the file */
|
||||
(void)lseek(fd,(d4size_t)0,SEEK_SET);
|
||||
stat = NC_NOERR;
|
||||
for(totalread=0;;) {
|
||||
ssize_t count = (d4size_t)read(fd,buf,sizeof(buf));
|
||||
if(count == 0)
|
||||
break; /*eof*/
|
||||
else if(count < 0) {
|
||||
stat = NC_EIO;
|
||||
nclog(NCLOGERR,"read failed: %s",filename);
|
||||
goto done;
|
||||
}
|
||||
ncbytesappendn(packet,buf,(unsigned long)count);
|
||||
totalread += count;
|
||||
}
|
||||
if(totalread < filesize) {
|
||||
stat = NC_EIO;
|
||||
nclog(NCLOGERR,"short read: |%s|=%lu read=%lu\n",
|
||||
filename,(unsigned long)filesize,(unsigned long)totalread);
|
||||
goto done;
|
||||
}
|
||||
|
||||
stat = NC_readfile(filename,packet);
|
||||
return THROW(stat);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user