MCPcopy Create free account
hub / github.com/apache/arrow / FileGetSize

Function FileGetSize

cpp/src/arrow/util/io_util.cc:1590–1616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1588Status FileSeek(int fd, int64_t pos) { return FileSeek(fd, pos, SEEK_SET); }
1589
1590Result<int64_t> FileGetSize(int fd) {
1591#if defined(_WIN32)
1592 struct __stat64 st;
1593#else
1594 struct stat st;
1595#endif
1596 st.st_size = -1;
1597
1598#if defined(_WIN32)
1599 int ret = _fstat64(fd, &st);
1600#else
1601 int ret = fstat(fd, &st);
1602#endif
1603
1604 if (ret == -1) {
1605 return Status::IOError("error stat()ing file");
1606 }
1607 if (st.st_size == 0) {
1608 // Maybe the file doesn't support getting its size, double-check by
1609 // trying to tell() (seekable files usually have a size, while
1610 // non-seekable files don't)
1611 RETURN_NOT_OK(FileTell(fd));
1612 } else if (st.st_size < 0) {
1613 return Status::IOError("error getting file size");
1614 }
1615 return st.st_size;
1616}
1617
1618//
1619// Reading data

Callers 4

TEST_FFunction · 0.85
OpenWritableMethod · 0.85
OpenReadableMethod · 0.85
CheckConcreteFileFunction · 0.85

Calls 2

IOErrorFunction · 0.85
FileTellFunction · 0.85

Tested by 2

TEST_FFunction · 0.68
CheckConcreteFileFunction · 0.68