BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balb_filecleanerutil

Detailed Description

Outline

Purpose

Provide a utility class for configuration-based file removal.

Classes

See also
balb_filecleanerconfiguration

Description

This component defines a struct, balb::FileCleanerUtil, that provides a utility function for removing files based on a configuration.

General Features and Behavior

The removeFiles function implements generic filename pattern matching and removal logic. The user is responsible for calling this function with parameters that do not cause any interference with the application logic. Specifically, the user must pay attention to the supplied pattern to avoid removal of important application data files. See balb_filecleanerconfiguration for further information.

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

The following snippets of code illustrate the basic usage of balb::FileCleanerUtil.

Let's assume that the application was set up to log to files having the following pattern:

const char *appLogFilePattern = "/var/log/myApp/log*";

We want to clean up all the files older then a week, but leave at least 4 latest log files. First, we create a cleanup configuration object that will capture our parameters:

appLogFilePattern,
4);
Definition balb_filecleanerconfiguration.h:161
Definition bsls_timeinterval.h:301
static const bsls::Types::Int64 k_SECONDS_PER_DAY
Definition bdlt_timeunitratio.h:256

Then, we use this configuration to do a file cleanup:

static void removeFiles(const FileCleanerConfiguration &config)