1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 #include "nel/misc/sstring.h"
26 #include "nel/misc/md5.h"
28 #include "file_manager.h"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 NLMISC::CSString
getRepositoryIndexFileName(const NLMISC::CSString
& repositoryName
);
36 uint32
getFileVersion(const NLMISC::CSString
& fileName
);
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
51 NLMISC::CHashKeyMD5 Checksum
;
53 CFilesMapEntry(): FileSize(0), FileTime(0) {}
54 void set(uint32 fileSize
,uint32 fileTime
,const NLMISC::CHashKeyMD5
& checksum
)
61 typedef std::map
<NLMISC::CSString
,CFilesMapEntry
> TFiles
;
62 typedef TFiles::iterator iterator
;
63 typedef TFiles::const_iterator const_iterator
;
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
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
102 const CFilesMapEntry
& operator[](const NLMISC::CSString
&) const;
104 iterator
find(const NLMISC::CSString
&);
105 const_iterator
find(const NLMISC::CSString
&) const;
108 const_iterator
begin() const;
111 const_iterator
end() const;
113 void fillShortList(PATCHMAN::TFileInfoVector
&files
) const;
118 NLMISC::CSString _Name
;
119 NLMISC::CSString _TargetDirectory
;
120 uint32 _Version
; // The version number for the patch set to synchronise
125 //-----------------------------------------------------------------------------