blocxx
FileSystemMockObject.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2005, Quest Software, Inc. All rights reserved.
3 * Copyright (C) 2006, Novell, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of
14 * Quest Software, Inc.,
15 * nor Novell, Inc.,
16 * nor the names of its contributors or employees may be used to
17 * endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *******************************************************************************/
32 
33 
38 #ifndef BLOCXX_FILE_SYSTEM_MOCK_OBJECT_HPP_INCLUDE_GUARD_
39 #define BLOCXX_FILE_SYSTEM_MOCK_OBJECT_HPP_INCLUDE_GUARD_
40 #include "blocxx/BLOCXX_config.h"
41 #include "blocxx/CommonFwd.hpp"
42 #include "blocxx/Types.hpp"
43 #include "blocxx/FileSystem.hpp"
44 #include <cstddef>
45 #include <utility>
46 
47 namespace BLOCXX_NAMESPACE
48 {
53  {
54  public:
55  virtual ~FileSystemMockObject();
56  virtual File openFile(const String& path);
57  virtual File createFile(const String& path);
58  virtual File openOrCreateFile(const String& path);
59  virtual File openForAppendOrCreateFile(const String& path);
60  virtual File createTempFile(const String& dir);
61  virtual File createTempFile(String& filePath, const String& dir);
62  virtual int changeFileOwner(const String& filename,
63  const UserId& userId);
64  virtual bool exists(const String& path);
65  #ifndef BLOCXX_WIN32
66  virtual bool isExecutable(const String& path);
67  #endif
68  virtual bool canRead(const String& path);
69  virtual bool canWrite(const String& path);
70  #ifndef BLOCXX_WIN32
71  virtual bool isLink(const String& path);
72  #endif
73  virtual bool isDirectory(const String& path);
74  virtual bool changeDirectory(const String& path);
75  #ifndef BLOCXX_WIN32
76  virtual bool makeDirectory(const String& path, int mode=0777);
77  #else
78  virtual bool makeDirectory(const String& path, int mode=-1);
79  #endif
80  virtual bool getFileSize(const String& path, Int64& size);
81  virtual UInt64 fileSize(FileHandle fh);
82  virtual bool removeDirectory(const String& path);
83  virtual bool removeFile(const String& path);
84  virtual bool getDirectoryContents(const String& path,
85  StringArray& dirEntries);
86  virtual bool renameFile(const String& oldFileName,
87  const String& newFileName);
88  virtual size_t read(const FileHandle& hdl, void* bfr, size_t numberOfBytes,
89  Int64 offset=-1L);
90  virtual size_t write(FileHandle hdl, const void* bfr,
91  size_t numberOfBytes, Int64 offset=-1L);
92  virtual Int64 seek(const FileHandle& hdl, Int64 offset, int whence);
93  virtual Int64 tell(const FileHandle& hdl);
94  virtual void rewind(const FileHandle& hdl);
95  virtual int close(const FileHandle& hdl);
96  virtual int flush(FileHandle& hdl);
97  virtual String getFileContents(const String& filename);
98  virtual StringArray getFileLines(const String& filename);
99  virtual String readSymbolicLink(const String& path);
100  virtual String realPath(const String& path);
101 
102  virtual std::pair<FileSystem::Path::ESecurity, String>
103  security(String const & path, UserId uid);
104 
105  virtual std::pair<FileSystem::Path::ESecurity, String> security(String const & path);
106 
107  virtual std::pair<FileSystem::Path::ESecurity, String>
108  security(String const & base_dir, String const & rel_path, UserId uid);
109 
110  virtual std::pair<FileSystem::Path::ESecurity, String>
111  security(String const & base_dir, String const & rel_path);
112 
113  virtual String dirname(const String& filename);
114  virtual String basename(const String& filename);
115 
117 
118 
119  };
120 
121 } // end namespace BLOCXX_NAMESPACE
122 
123 
124 #endif
125 
126