blocxx

FileSystemMockObject.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2005, Quest Software, Inc. All rights reserved.
00003 * Copyright (C) 2006, Novell, Inc. All rights reserved.
00004 * 
00005 * Redistribution and use in source and binary forms, with or without
00006 * modification, are permitted provided that the following conditions are met:
00007 * 
00008 *     * Redistributions of source code must retain the above copyright notice,
00009 *       this list of conditions and the following disclaimer.
00010 *     * Redistributions in binary form must reproduce the above copyright
00011 *       notice, this list of conditions and the following disclaimer in the
00012 *       documentation and/or other materials provided with the distribution.
00013 *     * Neither the name of 
00014 *       Quest Software, Inc., 
00015 *       nor Novell, Inc., 
00016 *       nor the names of its contributors or employees may be used to 
00017 *       endorse or promote products derived from this software without 
00018 *       specific prior written permission.
00019 * 
00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00024 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030 * POSSIBILITY OF SUCH DAMAGE.
00031 *******************************************************************************/
00032 
00033 
00038 #ifndef BLOCXX_FILE_SYSTEM_MOCK_OBJECT_HPP_INCLUDE_GUARD_
00039 #define BLOCXX_FILE_SYSTEM_MOCK_OBJECT_HPP_INCLUDE_GUARD_
00040 #include "blocxx/BLOCXX_config.h"
00041 #include "blocxx/CommonFwd.hpp"
00042 #include "blocxx/Types.hpp"
00043 #include "blocxx/FileSystem.hpp"
00044 #include <cstddef>
00045 #include <utility>
00046 
00047 namespace BLOCXX_NAMESPACE
00048 {
00052    class FileSystemMockObject
00053    {
00054    public:
00055       virtual ~FileSystemMockObject();
00056       virtual File openFile(const String& path);
00057       virtual File createFile(const String& path);
00058       virtual File openOrCreateFile(const String& path);
00059       virtual File openForAppendOrCreateFile(const String& path);
00060       virtual File createTempFile(const String& dir);
00061       virtual File createTempFile(String& filePath, const String& dir);
00062       virtual int changeFileOwner(const String& filename,
00063          const UserId& userId);
00064       virtual bool exists(const String& path);
00065    #ifndef BLOCXX_WIN32
00066       virtual bool isExecutable(const String& path);
00067    #endif
00068       virtual bool canRead(const String& path);
00069       virtual bool canWrite(const String& path);
00070    #ifndef BLOCXX_WIN32
00071       virtual bool isLink(const String& path);
00072    #endif
00073       virtual bool isDirectory(const String& path);
00074       virtual bool changeDirectory(const String& path);
00075    #ifndef BLOCXX_WIN32
00076       virtual bool makeDirectory(const String& path, int mode=0777);
00077    #else
00078       virtual bool makeDirectory(const String& path, int mode=-1);
00079    #endif
00080       virtual bool getFileSize(const String& path, Int64& size);
00081       virtual UInt64 fileSize(FileHandle fh);
00082       virtual bool removeDirectory(const String& path);
00083       virtual bool removeFile(const String& path);
00084       virtual bool getDirectoryContents(const String& path,
00085          StringArray& dirEntries);
00086       virtual bool renameFile(const String& oldFileName,
00087          const String& newFileName);
00088       virtual size_t read(const FileHandle& hdl, void* bfr, size_t numberOfBytes,
00089          Int64 offset=-1L);
00090       virtual size_t write(FileHandle hdl, const void* bfr,
00091          size_t numberOfBytes, Int64 offset=-1L);
00092       virtual Int64 seek(const FileHandle& hdl, Int64 offset, int whence);
00093       virtual Int64 tell(const FileHandle& hdl);
00094       virtual void rewind(const FileHandle& hdl);
00095       virtual int close(const FileHandle& hdl);
00096       virtual int flush(FileHandle& hdl);
00097       virtual String getFileContents(const String& filename);
00098       virtual StringArray getFileLines(const String& filename);
00099       virtual String readSymbolicLink(const String& path);
00100       virtual String realPath(const String& path);
00101 
00102       virtual std::pair<FileSystem::Path::ESecurity, String>
00103          security(String const & path, UserId uid);
00104 
00105       virtual std::pair<FileSystem::Path::ESecurity, String> security(String const & path);
00106 
00107       virtual std::pair<FileSystem::Path::ESecurity, String>
00108          security(String const & base_dir, String const & rel_path, UserId uid);
00109 
00110       virtual std::pair<FileSystem::Path::ESecurity, String>
00111          security(String const & base_dir, String const & rel_path);
00112 
00113       virtual String dirname(const String& filename);
00114       virtual String basename(const String& filename);
00115 
00116       virtual String getCurrentWorkingDirectory();
00117 
00118 
00119    };
00120 
00121 } // end namespace BLOCXX_NAMESPACE
00122 
00123 
00124 #endif
00125 
00126