Add infos into target window
[ryzomcore.git] / ryzom / server / src / patchman_service / repository.h
blobeb823b897f85b16e5e73387c706029af1ba75f45
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef REPOSITORY_H
18 #define REPOSITORY_H
21 //-----------------------------------------------------------------------------
22 // includes
23 //-----------------------------------------------------------------------------
25 #include "nel/misc/sstring.h"
26 #include "nel/misc/md5.h"
28 #include "file_manager.h"
31 //-----------------------------------------------------------------------------
32 // utility routines
33 //-----------------------------------------------------------------------------
35 NLMISC::CSString getRepositoryIndexFileName(const NLMISC::CSString& repositoryName);
36 uint32 getFileVersion(const NLMISC::CSString& fileName);
39 //-----------------------------------------------------------------------------
40 // class CRepository
41 //-----------------------------------------------------------------------------
43 class CRepository
45 public:
46 // local data types
47 struct CFilesMapEntry
49 uint32 FileSize;
50 uint32 FileTime;
51 NLMISC::CHashKeyMD5 Checksum;
53 CFilesMapEntry(): FileSize(0), FileTime(0) {}
54 void set(uint32 fileSize,uint32 fileTime,const NLMISC::CHashKeyMD5& checksum)
56 FileSize= fileSize;
57 FileTime= fileTime;
58 Checksum= checksum;
61 typedef std::map<NLMISC::CSString,CFilesMapEntry> TFiles;
62 typedef TFiles::iterator iterator;
63 typedef TFiles::const_iterator const_iterator;
65 public:
66 CRepository();
68 // setup the target directory and scan for files
69 // <name> defines the name used for temporary files and index files
70 // <directory> defines the root directory to be managed by the repository
71 // <filespec> defines the file specs that should be checked. eg: "*" or "*.bat;*.btm"
72 // <avoid> defines the vector of files that block the normal update behaviour eg "toto/tata/??_busy_*" or "abc/def;ghi/jkl"
73 // - if any of the 'avoid' files exist then we assume that some process is modifying the repository and we should wait for it to finish
74 bool init(const NLMISC::CSString& name,const NLMISC::CSString& directory);
76 // rescan target directory looking for new files and files that have changed
77 uint32 update();
79 // create a stub entry for a given file
80 // - this needs to be called before calling 'updateFile()' for the first time
81 void addFileStub(NLMISC::CSString fileName);
83 // update the entry for a given file
84 // - if the file is new then addFileStub() needs to be called first
85 void updateFile(NLMISC::CSString fileName);
87 // write index file to disk
88 // this is called automatically by init() and update() but needs to be called by hand after manual
89 // manipulation of map entries
90 void writeIndexFile();
92 // display info about the repository (version number, directory names, etc)
93 void display(NLMISC::CLog& log=*NLMISC::InfoLog) const;
95 // accessors for the version number
96 uint32 getVersion() const;
97 void setVersion(uint32 version);
99 // wrapping of the stl map container interface
100 uint32 size() const;
102 const CFilesMapEntry& operator[](const NLMISC::CSString&) const;
104 iterator find(const NLMISC::CSString&);
105 const_iterator find(const NLMISC::CSString&) const;
107 iterator begin();
108 const_iterator begin() const;
110 iterator end();
111 const_iterator end() const;
113 void fillShortList(PATCHMAN::TFileInfoVector &files) const;
115 private:
117 // private data
118 NLMISC::CSString _Name;
119 NLMISC::CSString _TargetDirectory;
120 uint32 _Version; // The version number for the patch set to synchronise
121 TFiles _Files;
125 //-----------------------------------------------------------------------------
126 #endif