ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/DecentralizedMedia.cpp
(Generate patch)

Comparing DecentralizedMedia/DecentralizedMedia.cpp (file contents):
Revision 492 by douglas, 2005-06-17T03:25:01-07:00 vs.
Revision 493 by douglas, 2005-06-17T03:26:33-07:00

# Line 35 | Line 35 | int Main(const app::Options& options)
35          if (extensions.IsEmpty())
36                  extensions.Insert(_B("mp3"));
37  
38 <        locals.Insert("Media");
38 >        if (!api::Path(_B("Media")).Exists())
39 >                api::Posix::CheckError(::mkdir("Media", 0755));
40 >
41 >        locals.Insert(_B("Media"));
42  
43          _S<DecentralizedMedia> media(extensions, locals);
44  
# Line 46 | Line 49 | int Main(const app::Options& options)
49  
50   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("pgsql")->Connect("", "douglas", "", "media")), extensions(extensions)
51   {
52 <        if (!locals.IsEmpty())
52 >        foreach (const ext::RedBlackSet<ext::String>, local, locals) if (!connection->Parse(_B("SELECT path FROM folders WHERE path = ?"))->Execute(*local)->MoveNext())
53 >                connection->Parse(_B("INSERT INTO folders (path) VALUES (?)"))->Execute(*local);
54 >
55          {
56                  _L<ext::String> args(locals.Begin(), locals.End());
57  
58 +                args.InsertLast(_B("-type"));
59 +                args.InsertLast(_B("d"));
60 +
61                  _foreach (const ext::RedBlackSet<ext::String>, extension, extensions)
62                  {
63 <                        if (extension != _set.Begin())
56 <                                args.InsertLast(_B("-or"));
57 <
63 >                        args.InsertLast(_B("-or"));
64                          args.InsertLast(_B("-iname"));
65                          args.InsertLast(_S<ios::String>() << _B("*.") << *extension);
66                  }
# Line 62 | Line 68 | DecentralizedMedia::DecentralizedMedia(c
68                  _H<api::Process> find(new api::Process(_B("/usr/bin/find"), args));
69                  ext::String file;
70  
71 <                while (ios::ReadLine(*find->GetReader(), file))
72 <                        /*media.Insert(file)*/;
71 >                while (ios::ReadLine(*find->GetReader(), file)) if (!locals.Contains(file))
72 >                {
73 >                }
74  
75                  find->Join();
76          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines