Apache log4cxx  Version 0.12.0
file.h
Go to the documentation of this file.
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 
24 #if defined(_MSC_VER)
25  #pragma warning ( push )
26  #pragma warning ( disable: 4251 )
27 #endif
28 
29 extern "C" {
30  struct apr_file_t;
31  struct apr_finfo_t;
32 }
33 
34 namespace log4cxx
35 {
36 namespace helpers
37 {
38 class Transcoder;
39 class Pool;
40 }
41 
45 class LOG4CXX_EXPORT File
46 {
47  public:
51  File();
56  File(const char* path);
61  File(const std::string& path);
62 #if LOG4CXX_WCHAR_T_API
63 
67  File(const wchar_t* path);
72  File(const std::wstring& path);
73 #endif
74 #if LOG4CXX_UNICHAR_API
75 
79  File(const UniChar* path);
84  File(const std::basic_string<UniChar>& path);
85 #endif
86 #if LOG4CXX_CFSTRING_API
87 
91  File(const CFStringRef& path);
92 #endif
93 
96  File(const File& src);
100  File& operator=(const File& src);
104  ~File();
105 
111  bool exists(log4cxx::helpers::Pool& p) const;
117  size_t length(log4cxx::helpers::Pool& p) const;
123  log4cxx_time_t lastModified(log4cxx::helpers::Pool& p) const;
128  LogString getName() const;
133  LogString getPath() const;
137  File& setPath(const LogString&);
138 
147  log4cxx_status_t open(apr_file_t** file, int flags,
148  int perm, log4cxx::helpers::Pool& p) const;
149 
155  std::vector<LogString> list(log4cxx::helpers::Pool& p) const;
156 
162  bool deleteFile(log4cxx::helpers::Pool& p) const;
169  bool renameTo(const File& dest, log4cxx::helpers::Pool& p) const;
170 
176  LogString getParent(log4cxx::helpers::Pool& p) const;
182  bool mkdirs(log4cxx::helpers::Pool& p) const;
183 
184  private:
185  LogString path;
186  static char* convertBackSlashes(char*);
187  char* getPath(log4cxx::helpers::Pool& p) const;
188 };
189 } // namespace log4cxx
190 
191 
192 #if defined(_MSC_VER)
193  #pragma warning (pop)
194 #endif
195 
196 #define LOG4CXX_FILE(name) log4cxx::File(name)
197 
198 #endif // _LOG4CXX_FILE_H
unsigned short UniChar
Definition: logstring.h:44
const struct __CFString * CFStringRef
Definition: logstring.h:36
Definition: pool.h:32
An abstract representation of file and directory path names.
Definition: file.h:45
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66