DCL 3.7.4
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"
#include "Version.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 102 of file work/mediatag/main.cpp.

103{
104 __DCL_ASSERT(!_args.values().isEmpty());
105 String path = _args.values()[0];
106 if (_args.summary()) {
107 TagCounter counter;
108 if (Files::isDirectory(path)) {
109 TagCounter::readDir(path, counter, _args);
110 }
111 else {
112 TagCounter::read(path, counter);
113 }
114
115 _args.output() << L"[" << path << L"] " << counter.toString() << endl;
116 return;
117 }
118
119 TagReader reader(_args);
120 if (Files::isDirectory(path)) {
121 reader.readDir(path);
122 }
123 else {
124 reader.read(Files::dirname(path), Files::basename(path));
125 }
126}
#define __DCL_ASSERT(expr)
Definition Object.h:394
DCLCVAR const struct __endl endl
static String dirname(const String &_path)
Definition Files.cpp:268
static String basename(const String &_path)
Definition Files.cpp:252
static bool isDirectory(const String &_path)
Definition Files.cpp:115
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 132 of file work/mediatag/main.cpp.

133{
134 // std::locale::global(std::locale(""));
135 setlocale(LC_ALL, "");
136
138 try {
141#ifdef __DCL_DEBUG
142 DCLDebugSetGlobalReport(&errout);
143#endif
144 MainArguments args(output, errout);
145 if (args.parse(argc, argv)) {
146 String sep(L'=', 80);
147 output << L"Start [" << DateTime::getCurrentLocalTime().toString()
148 << L"]" << endl;
149 if (args.verbose()) {
150 output << L" [" << args.toString() << L"]" << endl;
151 }
152 output << sep << endl;
153
155 try {
156 __main(args);
157 }
158 catch (Exception* e) {
159 errout << e->toStringAll() << endl;
160 e->destroy();
161 }
163
164 output << sep << endl
165 << L"Finish [" << DateTime::getCurrentLocalTime().toString()
166 << L"]" << endl;
167 }
168#ifdef __DCL_DEBUG
169#if __DCL_HAVE_ALLOC_DEBUG
170 DCLDebugDumpGlobalMemoryLeak(DCL_ALLOC_DUMP_ALL, &errout);
171#endif
172 DCLDebugSetGlobalReport(NULL);
173#endif // __DCL_DEBUG
174 }
175 catch(Exception* e) {
176 String s = e->toStringAll();
177 e->destroy();
178 fwprintf(stderr, L"Warning!! Final Exception: %ls\n", s.data());
179 }
181
182 return 0;
183}
#define NULL
Definition Config.h:312
#define STDOUT_HANDLE
Definition File.h:59
#define STDERR_HANDLE
Definition File.h:60
#define __DCL_CLEANUP
Definition Object.h:286
#define __DCL_INITIALIZE
Definition Object.h:285
String toString() const
Definition DateTime.cpp:843
static DateTime getCurrentLocalTime()
Definition DateTime.cpp:954
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
static void cleanup()
Definition MediaInfo.cpp:67
static void initialize() __DCL_THROWS1(DllException *)
Definition MediaInfo.cpp:51
void __main(const MainArguments &_args)