Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JStat.cc File Reference

Example program to print status of file. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JSystem/JStat.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

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

Detailed Description

Example program to print status of file.

Author
mdejong

Definition in file JStat.cc.

Function Documentation

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

Definition at line 16 of file JStat.cc.

17 {
18  using namespace std;
19 
20  string file_name;
21 
22  try {
23 
24  JParser<> zap("Example program to print status of file.");
25 
26  zap['f'] = make_field(file_name) = argv[0];
27 
28  zap(argc, argv);
29  }
30  catch(const exception &error) {
31  FATAL(error.what() << endl);
32  }
33 
34 
35  using namespace JPP;
36 
37  const JStat jas(file_name.c_str());
38 
39  if (jas.getError() == 0) {
40 
41  cout << "UID " << jas.getUID() << endl;
42  cout << "GID " << jas.getGID() << endl;
43  cout << "Size [B] " << jas.getSize() << endl;
44  cout << "Last access " << jas.getTimeOfLastAccess() << endl;
45  cout << "Last modified " << jas.getTimeOfLastModification() << endl;
46  cout << "Last changed " << jas.getTimeOfLastChange() << endl;
47 
48  } else {
49 
50  cout << "error: " << file_name << std::endl;
51  }
52 }
Utility class to parse command line options.
Definition: JParser.hh:1711
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define FATAL(A)
Definition: JMessage.hh:67