source: pacpusframework/branches/2.0-beta1/3rd/apache-log4cxx/include/log4cxx/file.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 7.2 KB
Line 
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#ifndef _LOG4CXX_FILE_H
19#define _LOG4CXX_FILE_H
20
21#include <log4cxx/logger.h>
22#include <log4cxx/logstring.h>
23
24extern "C" {
25struct apr_file_t;
26struct apr_finfo_t;
27}
28
29namespace log4cxx
30{
31 namespace helpers {
32 class Transcoder;
33 class Pool;
34 }
35
36 /**
37 * An abstract representation of file and directory path names.
38 */
39 class LOG4CXX_EXPORT File
40 {
41 public:
42 /**
43 * Construct a new instance.
44 */
45 File();
46 /**
47 * Construct a new instance. Use setPath to specify path using a LogString.
48 * @param path file path in local encoding.
49 */
50 File(const char* path);
51 /**
52 * Construct a new instance. Use setPath to specify path using a LogString.
53 * @param path file path in current encoding.
54 */
55 File(const std::string& path);
56#if LOG4CXX_WCHAR_T_API
57 /**
58 * Construct a new instance. Use setPath to specify path using a LogString.
59 * @param path file path.
60 */
61 File(const wchar_t* path);
62 /**
63 * Construct a new instance. Use setPath to specify path using a LogString.
64 * @param path file path.
65 */
66 File(const std::wstring& path);
67#endif
68#if LOG4CXX_UNICHAR_API
69 /**
70 * Construct a new instance. Use setPath to specify path using a LogString.
71 * @param path file path.
72 */
73 File(const UniChar* path);
74 /**
75 * Construct a new instance. Use setPath to specify path using a LogString.
76 * @param path file path.
77 */
78 File(const std::basic_string<UniChar>& path);
79#endif
80#if LOG4CXX_CFSTRING_API
81 /**
82 * Construct a new instance. Use setPath to specify path using a LogString.
83 * @param path file path.
84 */
85 File(const CFStringRef& path);
86#endif
87 /**
88 * Copy constructor.
89 */
90 File(const File& src);
91 /**
92 * Assignment operator.
93 */
94 File& operator=(const File& src);
95 /**
96 * Destructor.
97 */
98 ~File();
99
100 /**
101 * Determines if file exists.
102 * @param p pool.
103 * @return true if file exists.
104 */
105 bool exists(log4cxx::helpers::Pool& p) const;
106 /**
107 * Determines length of file. May not be accurate if file is current open.
108 * @param p pool.
109 * @return length of file.
110 */
111 size_t length(log4cxx::helpers::Pool& p) const;
112 /**
113 * Determines last modification date.
114 * @param p pool.
115 * @return length of file.
116 */
117 log4cxx_time_t lastModified(log4cxx::helpers::Pool& p) const;
118 /**
119 * Get final portion of file path.
120 * @return file name.
121 */
122 LogString getName() const;
123 /**
124 * Get file path.
125 * @return file path.
126 */
127 LogString getPath() const;
128 /**
129 * Set file path
130 */
131 File& setPath(const LogString&);
132
133 /**
134 * Open file. See apr_file_open for details.
135 * @param file APR file handle.
136 * @param flags flags.
137 * @param perm permissions.
138 * @param p pool.
139 * @return APR_SUCCESS if successful.
140 */
141 log4cxx_status_t open(apr_file_t** file, int flags,
142 int perm, log4cxx::helpers::Pool& p) const;
143
144 /**
145 * List files if current file is a directory.
146 * @param p pool.
147 * @return list of files in this directory, operation of non-directory returns empty list.
148 */
149 std::vector<LogString> list(log4cxx::helpers::Pool& p) const;
150
151 /**
152 * Delete file.
153 * @param p pool.
154 * @return true if file successfully deleted.
155 */
156 bool deleteFile(log4cxx::helpers::Pool& p) const;
157 /**
158 * Rename file.
159 * @param dest new path for file.
160 * @param p pool.
161 * @return true if file successfully renamed.
162 */
163 bool renameTo(const File& dest, log4cxx::helpers::Pool& p) const;
164
165 /**
166 * Get path of parent directory.
167 * @param p pool.
168 * @return path of parent directory.
169 */
170 LogString getParent(log4cxx::helpers::Pool& p) const;
171 /**
172 * Make directories recursively.
173 * @param p pool.
174 * @return true if all requested directories existed or have been created.
175 */
176 bool mkdirs(log4cxx::helpers::Pool& p) const;
177
178 private:
179 LogString path;
180 static char* convertBackSlashes(char*);
181 char* getPath(log4cxx::helpers::Pool& p) const;
182 };
183} // namespace log4cxx
184
185
186#define LOG4CXX_FILE(name) log4cxx::File(name)
187
188#endif // _LOG4CXX_FILE_H
Note: See TracBrowser for help on using the repository browser.