add get_file_size()

This commit is contained in:
David Rose
2005-01-18 19:15:53 +00:00
parent 86f270b5ec
commit 00990fb767
9 changed files with 129 additions and 9 deletions
@@ -79,6 +79,30 @@ open_read_file(const Filename &file) const {
return stream;
}
////////////////////////////////////////////////////////////////////
// Function: VirtualFileMountSystem::get_file_size
// Access: Published, Virtual
// Description: Returns the current size on disk (or wherever it is)
// of the already-open file. Pass in the stream that
// was returned by open_read_file(); some
// implementations may require this stream to determine
// the size.
////////////////////////////////////////////////////////////////////
streampos VirtualFileMountSystem::
get_file_size(const Filename &, istream *stream) const {
// First, save the original stream position.
streampos orig = stream->tellg();
// Seek to the end and get the stream position there.
stream->seekg(0, ios::end);
streampos size = stream->tellg();
// Then return to the original point.
stream->seekg(orig, ios::beg);
return size;
}
////////////////////////////////////////////////////////////////////
// Function: VirtualFileMountSystem::scan_directory
// Access: Public, Virtual