• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  file_size program  -------------------------------------------------------//
2 
3 //  Copyright Beman Dawes, 2004
4 
5 //  Use, modification, and distribution is subject to the Boost Software
6 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 //  http://www.boost.org/LICENSE_1_0.txt)
8 
9 //  See http://www.boost.org/libs/filesystem for documentation.
10 
11 #include <boost/filesystem/operations.hpp>
12 #include <iostream>
13 
14 namespace fs = boost::filesystem;
15 
main(int argc,char * argv[])16 int main( int argc, char* argv[] )
17 {
18 
19   if ( argc != 2 )
20   {
21     std::cout << "Usage: file_size path\n";
22     return 1;
23   }
24 
25   std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << '\n';
26 
27   fs::path p( argv[1] );
28 
29   if ( !fs::exists( p ) )
30   {
31     std::cout << "not found: " << argv[1] << std::endl;
32     return 1;
33   }
34 
35   if ( !fs::is_regular( p ) )
36   {
37     std::cout << "not a regular file: " << argv[1] << std::endl;
38     return 1;
39   }
40 
41   std::cout << "size of " << argv[1] << " is " << fs::file_size( p )
42     << std::endl;
43   return 0;
44 }
45