FileSystem.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2004 Vintela, Inc. All rights reserved.
00003 * Copyright (C) 2005 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 *
00011 *  - Redistributions in binary form must reproduce the above copyright notice,
00012 *    this list of conditions and the following disclaimer in the documentation
00013 *    and/or other materials provided with the distribution.
00014 *
00015 *  - Neither the name of Vintela, Inc., Novell, Inc., nor the names of its
00016 *    contributors may be used to endorse or promote products derived from this
00017 *    software without specific prior written permission.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc., Novell, Inc., OR THE 
00023 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00025 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00026 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00027 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00028 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00029 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 *******************************************************************************/
00031 
00032 
00038 #ifndef BLOCXX_FILESYSTEM_HPP_INCLUDE_GUARD_
00039 #define BLOCXX_FILESYSTEM_HPP_INCLUDE_GUARD_
00040 #include "blocxx/BLOCXX_config.h"
00041 #include "blocxx/Types.hpp"
00042 #include "blocxx/ArrayFwd.hpp"
00043 #include "blocxx/Exception.hpp"
00044 #include "blocxx/CommonFwd.hpp"
00045 
00046 #ifdef BLOCXX_HAVE_SYS_PARAM_H
00047 #include <sys/param.h>
00048 #endif
00049 #ifndef MAXPATHLEN
00050 #ifdef PATH_MAX
00051 #define MAXPATHLEN PATH_MAX
00052 #else
00053 #define MAXPATHLEN 1024
00054 #endif
00055 #endif
00056 
00057 namespace BLOCXX_NAMESPACE
00058 {
00059 
00060 BLOCXX_DECLARE_APIEXCEPTION(FileSystem, BLOCXX_COMMON_API)
00061 
00062 
00066 namespace FileSystem
00067 {
00072    BLOCXX_COMMON_API File openFile(const String& path);
00080    BLOCXX_COMMON_API File createFile(const String& path);
00087    BLOCXX_COMMON_API File openOrCreateFile(const String& path);
00094    BLOCXX_COMMON_API int changeFileOwner(const String& filename,
00095       const UserId& userId);
00099    BLOCXX_COMMON_API bool exists(const String& path);
00100 #ifndef BLOCXX_WIN32
00101 
00109    BLOCXX_COMMON_API bool isExecutable(const String& path);
00110 #endif
00111 
00114    BLOCXX_COMMON_API bool canRead(const String& path);
00118    BLOCXX_COMMON_API bool canWrite(const String& path);
00119 #ifndef BLOCXX_WIN32
00120 
00128    BLOCXX_COMMON_API bool isLink(const String& path);
00129 #endif
00130 
00133    BLOCXX_COMMON_API bool isDirectory(const String& path);
00139    BLOCXX_COMMON_API bool changeDirectory(const String& path);
00146    BLOCXX_COMMON_API bool makeDirectory(const String& path, int mode=0777);
00153    BLOCXX_COMMON_API bool getFileSize(const String& path, off_t& size);
00159    BLOCXX_COMMON_API bool removeDirectory(const String& path);
00165    BLOCXX_COMMON_API bool removeFile(const String& path);
00172    BLOCXX_COMMON_API bool getDirectoryContents(const String& path,
00173       StringArray& dirEntries);
00180    BLOCXX_COMMON_API bool renameFile(const String& oldFileName,
00181       const String& newFileName);
00193    BLOCXX_COMMON_API size_t read(const FileHandle& hdl, void* bfr, size_t numberOfBytes,
00194       off_t offset=-1L);
00205    BLOCXX_COMMON_API size_t write(FileHandle& hdl, const void* bfr,
00206       size_t numberOfBytes, off_t offset=-1L);
00218    BLOCXX_COMMON_API off_t seek(const FileHandle& hdl, off_t offset, int whence);
00224    BLOCXX_COMMON_API off_t tell(const FileHandle& hdl);
00230    BLOCXX_COMMON_API void rewind(const FileHandle& hdl);
00236    BLOCXX_COMMON_API int close(const FileHandle& hdl);
00241    BLOCXX_COMMON_API int flush(FileHandle& hdl);
00249    BLOCXX_COMMON_API String getFileContents(const String& filename);
00250    
00258    BLOCXX_COMMON_API StringArray getFileLines(const String& filename);
00259 
00266    BLOCXX_COMMON_API String readSymbolicLink(const String& path);
00267 
00268    namespace Path
00269    {
00280       BLOCXX_COMMON_API String realPath(const String& path);
00281 
00292       BLOCXX_COMMON_API String dirname(const String& filename);
00293 
00300       BLOCXX_COMMON_API String getCurrentWorkingDirectory();
00301 
00302 
00303    } // end namespace Path
00304 
00305 } // end namespace FileSystem
00306 
00307 } // end namespace BLOCXX_NAMESPACE
00308 
00309 #endif

Generated on Fri Jun 16 15:39:08 2006 for blocxx by  doxygen 1.4.6