Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JStat.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "JSystem/JStat.hh"
6#include "Jeep/JParser.hh"
7#include "Jeep/JMessage.hh"
8
9
10/**
11 * \file
12 *
13 * Example program to print status of file.
14 * \author mdejong
15 */
16int main(int argc, char* argv[])
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}
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char *argv[])
Definition JStat.cc:16
File status.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for file status.
Definition JStat.hh:31
off_t getSize() const
Get size of file.
Definition JStat.hh:117
JDateAndTime getTimeOfLastChange() const
Get time of last change.
Definition JStat.hh:150
uid_t getUID() const
Get UID of file.
Definition JStat.hh:95
JDateAndTime getTimeOfLastModification() const
Get time of last modification.
Definition JStat.hh:139
uid_t getGID() const
Get GID of file.
Definition JStat.hh:106
int getError() const
Get error of last call.
Definition JStat.hh:161
JDateAndTime getTimeOfLastAccess() const
Get time of last access.
Definition JStat.hh:128