BDE 4.39.x 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.
110///
111/// See @ref balb_filecleanerutil
113 public:
114 // CLASS METHODS
115
116 /// Remove files based on the criteria given by the specified `config`.
117 /// Only those files for which `bdls::FilesystemUtil::isRegularFile`
118 /// returns `true` are considered for removal (symbolic links are not followed).
119 ///
120 /// \pre The behavior is undefined unless
121 /// `0 <= config.minNumFiles()`, `0 <= config.maxNumFiles()`, and
122 /// `config.minNumFiles() <= config.maxNumFiles()`.
123 static
125};
126
127} // close package namespace
128
129
130#endif
131
132// ----------------------------------------------------------------------------
133// Copyright 2017 Bloomberg Finance L.P.
134//
135// Licensed under the Apache License, Version 2.0 (the "License");
136// you may not use this file except in compliance with the License.
137// You may obtain a copy of the License at
138//
139// http://www.apache.org/licenses/LICENSE-2.0
140//
141// Unless required by applicable law or agreed to in writing, software
142// distributed under the License is distributed on an "AS IS" BASIS,
143// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144// See the License for the specific language governing permissions and
145// limitations under the License.
146// ----------------------------- END-OF-FILE ----------------------------------
147
148/** @} */
149/** @} */
150/** @} */
Definition balb_filecleanerconfiguration.h:166
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition balb_controlmanager.h:144
Definition balb_filecleanerutil.h:112
static void removeFiles(const FileCleanerConfiguration &config)