Boost logo

Boost Users :

Subject: [Boost-users] [filesystem] boost::filesystem::file_size fails on Solaris 11
From: Red Taza (redtaza_at_[hidden])
Date: 2011-05-07 08:03:29


Hi,

I have been trying to get filesystem::file_size() on boost_1_46_1 to work but am getting the following error:

$ ./tut1 tut1.cpp
boost::filesystem::file_size: Not owner: "tut1.cpp"

Note: To avoid core file I modified tut1.cpp so that it catches exceptions.

The permissions and ownership of tut1.cpp seem fine:
-rw-r--r-- 1 redtaza staff 760 2011-05-07 10:40 tut1.cpp

$ uname -a
SunOS lunar 5.11 snv_151a i86pc i386 i86pc Solaris

$ CC -V
CC: Sun C++ 5.11 SunOS_i386 2010/08/13
usage: CC [ options ] files. Use 'CC -flags' for details

$ CC -g -library=stlport4 -I/usr/local/boost_1_46_1/include tut1.cpp -o tut1 /usr/local/boost_1_46_1/lib/libboost_system.a /usr/local/boost_1_46_1/lib/libboost_filesystem.a

Boost was built with the toolset sun and no other options.

Also if I compile and run the following code (which I believe is similar to the code that file_size()) I get expected results:

#include <iostream>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdio>

int main(int argc, char* argv[])
{
  if (argc < 2)
  {
    std::cout << "Usage: tut1 path\n";
    return 1;
  }
    
  struct stat path_stat;
  if(::stat(argv[1], &path_stat)!= 0) {
    std::perror("stat() error: ");
    return -1;
  }

  if(!S_ISREG(path_stat.st_mode)) {
    std::cerr << argv[1] << " is not a regular file\n";
    return -1;
  }

  std::cout << path_stat.st_size << '\n';
  return 0;
}

$ CC -g -library=stlport4 -I/usr/local/boost_1_46_1/include getFilesize.cpp -o getFilesize /usr/local/boost_1_46_1/lib/libboost_system.a /usr/local/boost_1_46_1/lib/libboost_filesystem.a
$ ./getFilesize tut1.cpp
760

Thanks

                                               



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net