7 |
|
#include <menes/standard.hh> |
8 |
|
|
9 |
|
#include <menes-api/pcre/regex.hpp> |
10 |
– |
#include <menes-api/realpath.hpp> |
10 |
|
#include <menes-app/simple.hpp> |
11 |
|
#include <menes-dbi/driver.hpp> |
12 |
|
#include <menes-dbi/resultset.hpp> |
21 |
|
|
22 |
|
int Main(const app::Options& options) |
23 |
|
{ |
24 |
< |
ext::RedBlackSet<ext::String> extensions, locals; |
24 |
> |
_breakpoint(); |
25 |
> |
ext::RedBlackSet<ext::String> extensions; |
26 |
> |
ext::RedBlackSet<api::Path> locals; |
27 |
|
api::Pcre::RegEx extension(_B("^-extension=(.+)$")), local(_B("^-local=(.+)$")); |
28 |
|
|
29 |
|
_foreach (const app::ArgumentList, arg, app::GetArguments()) |
33 |
|
if (match = extension(*arg)) |
34 |
|
extensions.Insert(match[1]); |
35 |
|
else if (match = local(*arg)) |
36 |
< |
locals.Insert(api::RealPath(match[1])); |
36 |
> |
locals.Insert(api::Path(match[1]).GetRealPath()); |
37 |
|
} |
38 |
|
|
39 |
|
if (extensions.IsEmpty()) |
40 |
|
extensions.Insert(_B("mp3")); |
41 |
|
|
42 |
< |
if (!api::Path(_B("Media")).Exists()) |
43 |
< |
api::Posix::CheckError(::mkdir("Media", 0755)); |
44 |
< |
|
45 |
< |
locals.Insert(api::RealPath(_B("Media"))); |
42 |
> |
{ |
43 |
> |
api::Path media(_B("Media")); |
44 |
> |
|
45 |
> |
if (!media.Exists()) |
46 |
> |
media.CreateDirectory(); |
47 |
> |
|
48 |
> |
locals.Insert(media.GetRealPath()); |
49 |
> |
} |
50 |
|
|
51 |
|
_S<DecentralizedMedia> media(extensions, locals); |
52 |
|
|
55 |
|
return 0; |
56 |
|
} |
57 |
|
|
58 |
< |
DecentralizedMedia::DecentralizedMedia(const ext::RedBlackSet<ext::String>& extensions, const ext::RedBlackSet<ext::String>& locals) : waf::Server(_B("Web")), process(bmp.IsRunning() ? NULL : new api::Process(_B("/usr/X11R6/bin/beep-media-player"))), connection(dbi::GetDriver("dbi::PgSql::Driver")->Connect("", "douglas", "", "media")), extensions(extensions) |
58 |
> |
DecentralizedMedia::DecentralizedMedia(const ext::RedBlackSet<ext::String>& extensions, const ext::RedBlackSet<api::Path>& locals) : waf::Server(_B("Web")), process(bmp.IsRunning() ? NULL : new api::Process(_B("/usr/X11R6/bin/beep-media-player"))), connection(dbi::GetDriver("dbi::PgSql::Driver")->Connect("", "douglas", "", "media")), extensions(extensions) |
59 |
|
{ |
60 |
|
if (!process.IsEmpty()) |
61 |
|
{ |
71 |
|
_foreach (const ext::RedBlackSet<ext::String>, extension, extensions) |
72 |
|
args.InsertLast(_S<ios::String>() << "-extension=" << *extension); |
73 |
|
|
74 |
< |
_foreach (const ext::RedBlackSet<ext::String>, local, locals) |
74 |
> |
_foreach (const ext::RedBlackSet<api::Path>, local, locals) |
75 |
|
args.InsertLast(_S<ios::String>() << "-local=" << *local); |
76 |
|
|
77 |
|
_S<api::Process> media(_B("Util/media"), args); |