1 /* cclive
2  * Copyright (C) 2010-2013  Toni Gundogdu <legatvs@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef cclive_file_h
19 #define cclive_file_h
20 
21 namespace cc
22 {
23 
24 class file
25 {
26 public:
27   file(const quvi::media&);
28 
file()29   inline file(): _initial_length(0), _nothing_todo(false) { }
30 
file(const file & f)31   inline file(const file& f): _initial_length(0), _nothing_todo(false)
32     {
33       _swap(f);
34     }
35 
36   inline file& operator=(const file& f)
37     {
38       if (this != &f) _swap(f);
39       return *this;
40     }
41 public:
42   bool write(const quvi::media&, void*) const;
43 public:
44   std::string to_s(const quvi::media&) const;
title()45   inline const std::string& title() const { return _title; }
path()46   inline const std::string& path() const  { return _path; }
name()47   inline const std::string& name() const  { return _name; }
nothing_todo()48   inline const bool nothing_todo() const  { return _nothing_todo; }
initial_length()49   inline double initial_length() const    { return _initial_length; }
should_continue()50   inline bool should_continue() const     { return _initial_length >0; }
set_errmsg(const std::string & e)51   inline int set_errmsg(const std::string& e) { _errmsg = e; return 0; }
52 public:
53   static double exists(const std::string&);
54 private:
55   void _init(const quvi::media&);
56 
_swap(const file & f)57   inline void _swap(const file& f)
58     {
59       _title          = f._title;
60       _name           = f._name;
61       _path           = f._path;
62       _initial_length = f._initial_length;
63       _nothing_todo   = f._nothing_todo;
64     }
65 private:
66   double _initial_length;
67   std::string _errmsg;
68   bool _nothing_todo;
69   std::string _title;
70   std::string _name;
71   std::string _path;
72 };
73 
74 } // namespace cc
75 
76 #endif // cclive_file_h
77 
78 // vim: set ts=2 sw=2 tw=72 expandtab:
79