source: box/trunk/lib/backupclient/BackupClientMakeExcludeList.cpp @ 217

Revision 217, 2.1 KB checked in by martin, 6 years ago (diff)

Set svn:eol-style as appropriate for all files

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    BackupClientMakeExcludeList.cpp
5//              Purpose: Makes exclude lists from bbbackupd config location entries
6//              Created: 28/1/04
7//
8// --------------------------------------------------------------------------
9
10#include "Box.h"
11
12#include "BackupClientMakeExcludeList.h"
13#include "Configuration.h"
14#include "ExcludeList.h"
15
16#include "MemLeakFindOn.h"
17
18
19// --------------------------------------------------------------------------
20//
21// Function
22//              Name:    BackupClientMakeExcludeList(const Configuration &, const char *, const char *)
23//              Purpose: Given a Configuration object corresponding to a bbackupd Location, and the
24//                               two names of the keys for definite and regex entries, return a ExcludeList.
25//                               Or 0 if it isn't required.
26//              Created: 28/1/04
27//
28// --------------------------------------------------------------------------
29ExcludeList *BackupClientMakeExcludeList(const Configuration &rConfig, const char *DefiniteName, const char *RegexName,
30        const char *AlwaysIncludeDefiniteName, const char *AlwaysIncludeRegexName)
31{
32        // Check that at least one of the entries exists
33        if(!rConfig.KeyExists(DefiniteName) && !rConfig.KeyExists(RegexName))
34        {
35                // Neither exists -- return 0 as an Exclude list isn't required.
36                return 0;
37        }
38       
39        // Create the exclude list
40        ExcludeList *pexclude = new ExcludeList;
41
42        try
43        {
44                // Definite names to add?
45                if(rConfig.KeyExists(DefiniteName))
46                {
47                        pexclude->AddDefiniteEntries(rConfig.GetKeyValue(DefiniteName));
48                }
49                // Regular expressions to add?
50                if(rConfig.KeyExists(RegexName))
51                {
52                        pexclude->AddRegexEntries(rConfig.GetKeyValue(RegexName));
53                }
54               
55                // Add a "always include" list?
56                if(AlwaysIncludeDefiniteName != 0 && AlwaysIncludeRegexName != 0)
57                {
58                        // This will accept NULL as a valid argument, so safe to do this.
59                        pexclude->SetAlwaysIncludeList(
60                                        BackupClientMakeExcludeList(rConfig, AlwaysIncludeDefiniteName, AlwaysIncludeRegexName)
61                                );
62                }
63        }
64        catch(...)
65        {
66                // Clean up
67                delete pexclude;
68                throw;
69        }
70
71        return pexclude;
72}
73
74
75
Note: See TracBrowser for help on using the repository browser.