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 "rr_module_itf.h"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 NLMISC::CSString
getRepositoryIndexFileName(const NLMISC::CSString
& repositoryName
);
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
50 NLMISC::CHashKeyMD5 Checksum
;
52 CFilesMapEntry(): FileSize(0), FileTime(0) {}
53 void set(uint32 fileSize
,uint32 fileTime
,const NLMISC::CHashKeyMD5
& checksum
)
60 typedef std::map
<NLMISC::CSString
,CFilesMapEntry
> TFiles
;
61 typedef TFiles::iterator iterator
;
62 typedef TFiles::const_iterator const_iterator
;
65 // setup the target directory and scan for files
66 // <name> defines the name used for temporary files and index files
67 // <directory> defines the root directory to be managed by the repository
68 // <filespec> defines the file specs that should be checked. eg: "*" or "*.bat;*.btm"
69 // <avoid> defines the vector of files that block the normal update behaviour eg "toto/tata/??_busy_*" or "abc/def;ghi/jkl"
70 // - 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
71 bool init(const NLMISC::CSString
& name
,const NLMISC::CSString
& directory
,const NLMISC::CSString
& filespec
,const NLMISC::CSString
& lockFilespecs
);
73 // rescan target directory looking for new files and files that have changed
76 // create a stub entry for a given file
77 // - this needs to be called before calling 'updateFile()' for the first time
78 void addFileStub(NLMISC::CSString fileName
);
80 // update the entry for a given file
81 // - if the file is new then addFileStub() needs to be called first
82 void updateFile(NLMISC::CSString fileName
);
84 // write index file to disk
85 // this is called automatically by init() and update() but needs to be called by hand after manual
86 // manipulation of map entries
87 void writeIndexFile();
89 // wrapping of the stl map container interface
92 const CFilesMapEntry
& operator[](const NLMISC::CSString
&) const;
94 iterator
find(const NLMISC::CSString
&);
95 const_iterator
find(const NLMISC::CSString
&) const;
98 const_iterator
begin() const;
101 const_iterator
end() const;
103 void fillShortList(std::vector
<GUS_SCM::TFileRecord
> &files
) const;
108 NLMISC::CSString _Name
;
109 NLMISC::CSString _TargetDirectory
;
110 NLMISC::CVectorSString _Filespec
;
111 NLMISC::CVectorSString _LockFilespecs
;
112 NLMISC::CSString _BlockingFiles
;
117 //-----------------------------------------------------------------------------