BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balb_filecleanerutil.h
Go to the documentation of this file.
1/// @file balb_filecleanerutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// balb_filecleanerutil.h -*-C++-*-
8#ifndef INCLUDED_BALB_FILECLEANERUTIL
9#define INCLUDED_BALB_FILECLEANERUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup balb_filecleanerutil balb_filecleanerutil
15/// @brief Provide a utility class for configuration-based file removal.
16/// @addtogroup bal
17/// @{
18/// @addtogroup balb
19/// @{
20/// @addtogroup balb_filecleanerutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#balb_filecleanerutil-purpose"> Purpose</a>
25/// * <a href="#balb_filecleanerutil-classes"> Classes </a>
26/// * <a href="#balb_filecleanerutil-description"> Description </a>
27/// * <a href="#balb_filecleanerutil-general-features-and-behavior"> General Features and Behavior </a>
28/// * <a href="#balb_filecleanerutil-usage"> Usage </a>
29/// * <a href="#balb_filecleanerutil-example-1-basic-usage"> Example 1: Basic Usage </a>
30///
31/// # Purpose {#balb_filecleanerutil-purpose}
32/// Provide a utility class for configuration-based file removal.
33///
34/// # Classes {#balb_filecleanerutil-classes}
35///
36/// - balb::FileCleanerUtil: utility class for removing selected files
37///
38/// @see balb_filecleanerconfiguration
39///
40/// # Description {#balb_filecleanerutil-description}
41/// This component defines a `struct`, `balb::FileCleanerUtil`,
42/// that provides a utility function for removing files based on a
43/// configuration.
44///
45/// ## General Features and Behavior {#balb_filecleanerutil-general-features-and-behavior}
46///
47///
48/// The `removeFiles` function implements generic filename pattern matching and
49/// removal logic. The user is responsible for calling this function with
50/// parameters that do not cause any interference with the application logic.
51/// Specifically, the user must pay attention to the supplied pattern to avoid
52/// removal of important application data files. See
53/// @ref balb_filecleanerconfiguration for further information.
54///
55/// ## Usage {#balb_filecleanerutil-usage}
56///
57///
58/// This section illustrates intended use of this component.
59///
60/// ### Example 1: Basic Usage {#balb_filecleanerutil-example-1-basic-usage}
61///
62///
63/// The following snippets of code illustrate the basic usage of
64/// `balb::FileCleanerUtil`.
65///
66/// Let's assume that the application was set up to log to files having the
67/// following pattern:
68/// @code
69/// const char *appLogFilePattern = "/var/log/myApp/log*";
70/// @endcode
71/// We want to clean up all the files older then a week, but leave at least 4
72/// latest log files. First, we create a cleanup configuration object that will
73/// capture our parameters:
74/// @code
75/// balb::FileCleanerConfiguration config(
76/// appLogFilePattern,
77/// bsls::TimeInterval(bdlt::TimeUnitRatio::k_SECONDS_PER_DAY * 7),
78/// 4);
79/// @endcode
80/// Then, we use this configuration to do a file cleanup:
81/// @code
82/// balb::FileCleanerUtil::removeFiles(config);
83/// @endcode
84/// @}
85/** @} */
86/** @} */
87
88/** @addtogroup bal
89 * @{
90 */
91/** @addtogroup balb
92 * @{
93 */
94/** @addtogroup balb_filecleanerutil
95 * @{
96 */
97
98#include <balscm_version.h>
99
101
102
103namespace balb {
104
105 // ======================
106 // struct FileCleanerUtil
107 // ======================
108
109/// This utility class provides functions relating to file clean up.
111 public:
112 // CLASS METHODS
113
114 /// Remove files based on the criteria given by the specified `config`.
115 /// Only those files for which `bdls::FilesystemUtil::isRegularFile`
116 /// returns `true` are considered for removal (symbolic links are not
117 /// followed).
118 static
120};
121
122} // close package namespace
123
124
125#endif
126
127// ----------------------------------------------------------------------------
128// Copyright 2017 Bloomberg Finance L.P.
129//
130// Licensed under the Apache License, Version 2.0 (the "License");
131// you may not use this file except in compliance with the License.
132// You may obtain a copy of the License at
133//
134// http://www.apache.org/licenses/LICENSE-2.0
135//
136// Unless required by applicable law or agreed to in writing, software
137// distributed under the License is distributed on an "AS IS" BASIS,
138// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139// See the License for the specific language governing permissions and
140// limitations under the License.
141// ----------------------------- END-OF-FILE ----------------------------------
142
143/** @} */
144/** @} */
145/** @} */
Definition balb_filecleanerconfiguration.h:161
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balb_controlmanager.h:133
This utility class provides functions relating to file clean up.
Definition balb_filecleanerutil.h:110
static void removeFiles(const FileCleanerConfiguration &config)