Opened 12 years ago

Closed 12 years ago

#4823 closed Bugs (invalid)

tellg () function of ifstream object is returning -1 for /proc virtual file system files.

Reported by: pmanth2@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

The tellg function of ifstream object is returning -1 when the position of file pointer is queried for /proc virtual file system files. Below is the example program to demonstrate the problem

#include <iostream #include <fstream> using namespace std;

int main( int argc, char* argv[] ){

long begin,end; ifstream myfile (argv[1]); begin = myfile.tellg(); cout << " begin " << begin << endl; myfile.seekg (0, ios::end); end = myfile.tellg(); myfile.close(); cout << "size is: " << (end-begin) << " bytes.\n"; return 0;

}

pmanth2@cyder:~$ ./fstream partA.cpp ( Normal text file )

begin 0

size is: 6692 bytes.

pmanth2@cyder:~$ ./fstream /proc/cpuinfo ( virtual file system file )

begin 0

size is: -1 bytes.

The tellg() should return the file pointer location for /proc file system files also.

Change History (1)

comment:1 by Beman Dawes, 12 years ago

Resolution: invalid
Status: newclosed

This query is about how standard library <fstream> works; it has nothing to do with any Boost libraries. Thus I'm closing it as "invalid".

To find out why your code works the way it does, you might want to look at your operating systems's documentation of how virtual files are reported via the applications program interface (API).

HTH,

--Beman

Note: See TracTickets for help on using tickets.