/src/logging-log4cxx/src/main/cpp/filerenameaction.cpp
Line | Count | Source |
1 | | /* |
2 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
3 | | * contributor license agreements. See the NOTICE file distributed with |
4 | | * this work for additional information regarding copyright ownership. |
5 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 | | * (the "License"); you may not use this file except in compliance with |
7 | | * the License. You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <log4cxx/logstring.h> |
19 | | #include <log4cxx/rolling/filerenameaction.h> |
20 | | #include <log4cxx/private/action_priv.h> |
21 | | |
22 | | using namespace LOG4CXX_NS; |
23 | | using namespace LOG4CXX_NS::rolling; |
24 | | using namespace LOG4CXX_NS::helpers; |
25 | | |
26 | 0 | #define priv static_cast<FileRenameActionPrivate*>(m_priv.get()) |
27 | | |
28 | | struct FileRenameAction::FileRenameActionPrivate : public ActionPrivate |
29 | | { |
30 | | FileRenameActionPrivate |
31 | | ( const File& toRename |
32 | | , const File& renameTo |
33 | | , bool renameEmptyFile1 |
34 | | ) |
35 | 0 | : ActionPrivate{ LOG4CXX_STR("Rename") } |
36 | 0 | , source(toRename) |
37 | 0 | , destination(renameTo) |
38 | 0 | , renameEmptyFile(renameEmptyFile1) |
39 | 0 | {} |
40 | | |
41 | | const File source; |
42 | | const File destination; |
43 | | bool renameEmptyFile; |
44 | | }; |
45 | | |
46 | | IMPLEMENT_LOG4CXX_OBJECT(FileRenameAction) |
47 | | |
48 | | FileRenameAction::FileRenameAction(const File& toRename, |
49 | | const File& renameTo, |
50 | | bool renameEmptyFile1) |
51 | 0 | : Action( std::make_unique<FileRenameActionPrivate>(toRename, renameTo, renameEmptyFile1) ) |
52 | 0 | { |
53 | 0 | } Unexecuted instantiation: log4cxx::rolling::FileRenameAction::FileRenameAction(log4cxx::File const&, log4cxx::File const&, bool) Unexecuted instantiation: log4cxx::rolling::FileRenameAction::FileRenameAction(log4cxx::File const&, log4cxx::File const&, bool) |
54 | | |
55 | | #if LOG4CXX_ABI_VERSION <= 15 |
56 | | bool FileRenameAction::execute(Pool&) const |
57 | 0 | { |
58 | 0 | if (!priv->renameEmptyFile && 0 == priv->source.length()) |
59 | 0 | return false; |
60 | 0 | return priv->source.renameTo(priv->destination); |
61 | 0 | } |
62 | | #else |
63 | | bool FileRenameAction::execute()const |
64 | | { |
65 | | if (priv->renameEmptyFile || 0 != priv->source.length()) |
66 | | return priv->source.renameTo(priv->destination); |
67 | | return false; |
68 | | } |
69 | | #endif |