DCL 4.0
Loading...
Searching...
No Matches
main.cpp File Reference
#include <dcl/Config.h>
#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <dcl/Charset.h>
#include <dcl/Array.h>
#include <dcl/DateTime.h>
#include <dcl/FileWriter.h>
#include <dcl/Files.h>
#include <dcl/Arguments.h>
#include "MediaInfo.h"
#include "main.h"
#include "TagCounter.h"
#include "TagReader.h"

Go to the source code of this file.

Functions

void __main (const MainArguments &_args)
__DCL_END_NAMESPACE __DCL_USING_NAMESPACE int main (int argc, char *argv[])

Function Documentation

◆ __main()

void __main ( const MainArguments & _args)

Definition at line 97 of file mediatag/main.cpp.

98{
99 __DCL_ASSERT(!_args.values().isEmpty());
100 String path = _args.values()[0];
101 if (_args.summary()) {
102 TagCounter counter;
103 if (Files::isDirectory(path)) {
104 TagCounter::readDir(path, counter, _args);
105 }
106 else {
107 TagCounter::read(path, counter);
108 }
109
110 _args.output() << L"[" << path << L"] " << counter.toString() << endl;
111 return;
112 }
113
114 TagReader reader(_args);
115 if (Files::isDirectory(path)) {
116 reader.readDir(path);
117 }
118 else {
119 reader.read(Files::dirname(path), Files::basename(path));
120 }
121}
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define endl
static String dirname(const String &_path)
Definition Files.cpp:269
static String basename(const String &_path)
Definition Files.cpp:253
static bool isDirectory(const String &_path)
Definition Files.cpp:116
bool summary() const
static void read(const String &_filename, TagCounter &_counter)
String toString() const
Definition TagCounter.h:28
static void readDir(const String &_path, TagCounter &_counter, const MainArguments &_args)

◆ main()

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

Definition at line 127 of file mediatag/main.cpp.

128{
129 // std::locale::global(std::locale(""));
130 setlocale(LC_ALL, "");
131
133 try {
136#if __DCL_DEBUG
137 DCLDebugSetGlobalReport(&errout);
138#endif
139 MainArguments args(output, errout);
140 if (args.parse(argc, argv)) {
141 String sep(L'=', 80);
142 output << L"Start [" << DateTime::getCurrentLocalTime().toString()
143 << L"]" << endl;
144 if (args.verbose()) {
145 output << L" [" << args.toString() << L"]" << endl;
146 }
147 output << sep << endl;
148
150 try {
151 __main(args);
152 }
153 catch (Exception* e) {
154 errout << e->toStringAll() << endl;
155 e->destroy();
156 }
158
159 output << sep << endl
160 << L"Finish [" << DateTime::getCurrentLocalTime().toString()
161 << L"]" << endl;
162 }
163#if __DCL_DEBUG
164#if __DCL_HAVE_ALLOC_DEBUG
165 DCLDebugDumpGlobalMemoryLeak(DCL_ALLOC_DUMP_ALL, &errout);
166#endif
167 DCLDebugSetGlobalReport(NULL);
168#endif // __DCL_DEBUG
169 }
170 catch(Exception* e) {
171 String s = e->toStringAll();
172 e->destroy();
173 fwprintf(stderr, L"Warning!! Final Exception: %ls\n", s.data());
174 }
176
177 return 0;
178}
#define NULL
Definition Config.h:340
#define STDOUT_HANDLE
Definition File.h:55
#define STDERR_HANDLE
Definition File.h:56
#define __DCL_CLEANUP
Definition Object.h:269
#define __DCL_INITIALIZE
Definition Object.h:268
String toString() const
Definition DateTime.cpp:826
static DateTime getCurrentLocalTime()
Definition DateTime.cpp:937
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
static void cleanup()
Definition MediaInfo.cpp:55
static void initialize() __DCL_THROWS1(DllException *)
Definition MediaInfo.cpp:39
void __main(const MainArguments &_args)