]> git.mxchange.org Git - simgear.git/blob - simgear/io/SVNDirectory.hxx
SGPath: fix creating paths with permission checker.
[simgear.git] / simgear / io / SVNDirectory.hxx
1 // DAVCollectionMirror.hxx - mirror a DAV collection to the local filesystem
2 //
3 // Copyright (C) 2013  James Turner <zakalawe@mac.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19
20 #ifndef SG_IO_DAVCOLLECTIONMIRROR_HXX
21 #define SG_IO_DAVCOLLECTIONMIRROR_HXX
22
23 #include <string>
24 #include <vector>
25 #include <memory>
26
27 #include <simgear/misc/sg_path.hxx>
28 #include <simgear/misc/strutils.hxx>
29 #include <simgear/io/DAVMultiStatus.hxx>
30
31 namespace simgear  {
32
33 class Dir;
34 namespace HTTP { class Request; }
35
36 // forward decls
37 class DAVMirror;
38 class SVNRepository;
39 class SVNDirectory;
40
41 typedef std::vector<SVNDirectory*> DirectoryList;
42
43 class SVNDirectory
44 {
45 public:
46   // init from local
47   SVNDirectory(SVNRepository *repo, const SGPath& path);
48   ~SVNDirectory();
49   
50   void setBaseUrl(const std::string& url);
51   
52   // init from a collection
53   SVNDirectory(SVNDirectory* pr, DAVCollection* col);
54
55   void beginUpdateReport();
56   void updateReportComplete();
57   
58   bool isDoingSync() const;
59   
60   std::string url() const;
61   
62   std::string name() const;
63       
64   DAVResource* addChildFile(const std::string& fileName);
65   SVNDirectory* addChildDirectory(const std::string& dirName);
66       
67  // void updateChild(DAVResource* child);
68   void deleteChildByName(const std::string& name);
69   
70   SGPath fsPath() const
71     { return localPath; }
72   
73   simgear::Dir fsDir() const;
74   
75   std::string repoPath() const;
76     
77   SVNRepository* repository() const;
78   DAVCollection* collection() const
79     { return dav; }
80   
81   std::string cachedRevision() const
82       { return _cachedRevision; }
83   
84   void mergeUpdateReportDetails(unsigned int depth, string_list& items);
85   
86   SVNDirectory* parent() const;
87   SVNDirectory* child(const std::string& dirName) const;
88 private:
89   
90   void parseCache();
91   void writeCache();
92   
93   DirectoryList::iterator findChildDir(const std::string& dirName);
94       
95   SGPath localPath;
96   DAVCollection* dav;
97   SVNRepository* repo;
98   
99   std::string _cachedRevision;
100   bool _doingUpdateReport;
101   
102   SVNDirectory* _parent;
103   DirectoryList _children;
104 };
105
106 } // of namespace simgear
107
108 #endif // of SG_IO_DAVCOLLECTIONMIRROR_HXX