File: dir_it_tst.cpp

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (46 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// -*-C++-*- dir_it_tst.cpp
// <!!----------------------------------------------------------------------> 
// <!! Copyright (C) 1998 Dietmar Kuehl, Claas Solutions GmbH > 
// <!!> 
// <!! Permission to use, copy, modify, distribute and sell this > 
// <!! software for any purpose is hereby granted without fee, provided > 
// <!! that the above copyright notice appears in all copies and that > 
// <!! both that copyright notice and this permission notice appear in > 
// <!! supporting documentation. Dietmar Kuehl and Claas Solutions make no > 
// <!! representations about the suitability of this software for any > 
// <!! purpose. It is provided "as is" without express or implied warranty. > 
// <!!----------------------------------------------------------------------> 

// Author: Dietmar Kuehl dietmar.kuehl@claas-solutions.de 
// Title:  A simple test for the class 'dir_it'

// -------------------------------------------------------------------------- 

#include "boost/directory.h"
#include <iostream>
#include <algorithm>

// -------------------------------------------------------------------------- 

int main()
{
	using namespace boost::filesystem;

  for (dir_it it("./"); it != dir_it(); ++it)
		if (!get<is_hidden>(it))
			{
				std::cout << (get<is_directory>(it)? 'd': '-');
				std::cout << (get<user_read>(it)? 'r': '-');
				std::cout << (get<user_write>(it)? 'w': '-');
				std::cout << (get<user_execute>(it)? 'x': '-');
				
				std::cout.width(8);
				std::cout << get<size>(it) << ' ';
				
				char buf[128];
				buf[strftime(buf, sizeof(buf) - 1, "%b %d %H:%M", localtime(get<mtime>(it)))] = 0;
				std::cout << buf << ' ';
				
				std::cout << *it << "\n";
			}
}