Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4824: Boost file system function file_size() function is returning 0 for /proc virtual file system files. (was: tellg () function of ifstream object is returning -1 for /proc virtual file system files.)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-10 15:55:32
#4824: Boost file system function file_size() function is returning 0 for /proc
virtual file system files.
----------------------------------+-----------------------------------------
Reporter: pmanth2@⦠| Owner: bemandawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
Version: Boost 1.44.0 | Severity: Problem
Resolution: | Keywords:
----------------------------------+-----------------------------------------
Comment (by anonymous):
The boost filesystem function file_size returning 0 for /proc file system
files. Below is the example program to demonstrate the problem.
#include <boost/filesystem/operations.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int main( int argc, char* argv[] )
{
if ( argc != 2 )
{
std::cout << "Usage: file_size path\n";
return 1;
}
fs::path p( argv[1], fs::native );
if ( !fs::exists( p ) )
{
std::cout << "not found: " << argv[1] << std::endl;
return 1;
}
if ( !fs::is_regular( p ) )
{
std::cout << "not a regular file: " << argv[1] << std::endl;
return 1;
}
std::cout << "size of " << argv[1] << " is " << fs::file_size( p )
---------- boost file system file_size function
<< std::endl;
return 0;
}
Output:
pmanth2_at_cyder:~/new-saga-code/trunk/adaptors/default/file$ ./new k
size of k is 46
pmanth2_at_cyder:~/new-saga-code/trunk/adaptors/default/file$ wc -c k
46 k
pmanth2_at_cyder:~/new-saga-code/trunk/adaptors/default/file$ wc -c
/proc/cpuinfo
10102 /proc/cpuinfo
pmanth2_at_cyder:~/new-saga-code/trunk/adaptors/default/file$ ./new
/proc/cpuinfo
size of /proc/cpuinfo is 0 --------------------- ( should return actual
size of file just as word count )
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4824#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC