blocxx
PosixFileSystem.cpp File Reference
#include "blocxx/BLOCXX_config.h"
#include "blocxx/FileSystem.hpp"
#include "blocxx/Mutex.hpp"
#include "blocxx/MutexLock.hpp"
#include "blocxx/GlobalMutex.hpp"
#include "blocxx/File.hpp"
#include "blocxx/Array.hpp"
#include "blocxx/Format.hpp"
#include "blocxx/ExceptionIds.hpp"
#include "blocxx/Assertion.hpp"
#include "blocxx/GlobalPtr.hpp"
#include "blocxx/FileSystemMockObject.hpp"
#include "blocxx/AutoPtr.hpp"
#include "blocxx/SafeCString.hpp"
#include "blocxx/Logger.hpp"
#include "blocxx/GlobalString.hpp"
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <cstdio>
#include <fstream>
#include <cerrno>

Go to the source code of this file.

Namespaces

namespace  BLOCXX_NAMESPACE
 Taken from RFC 1321.
 
namespace  BLOCXX_NAMESPACE::FileSystem
 The purpose of the FileSystem class is to provide an abstraction layer over the platform dependant functionality related to a file system.
 
namespace  BLOCXX_NAMESPACE::FileSystem::Path
 

Macros

#define _ACCESS   ::access
 
#define _CHDIR   chdir
 
#define _MKDIR(a, b)
 
#define _RMDIR   rmdir
 
#define _UNLINK   unlink
 

Typedefs

typedef GlobalPtr< FileSystemMockObject, NullFactoryBLOCXX_NAMESPACE::FileSystem::FileSystemMockObject_t
 

Functions

BLOCXX_COMMON_API int BLOCXX_NAMESPACE::FileSystem::changeFileOwner (const String &filename, const UserId &userId)
 Change the given file ownership.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::openFile (const String &path)
 Open a file for read/write and return an File object that can be used for reading and writing.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::createFile (const String &path)
 Create the file for the given name.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::openOrCreateFile (const String &path)
 Opens or creates the file for the given name.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::openForAppendOrCreateFile (const String &path)
 Opens the file for the given name to append data or create if it does not exist.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::createTempFile (String &filePath, const String &dir=String())
 Create a tempororary file in an optional directory.
 
BLOCXX_COMMON_API File BLOCXX_NAMESPACE::FileSystem::createAutoDeleteTempFile (const String &dir=String())
 Create a tempororary file that will be removed when the returned File object is closed.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::exists (const String &path)
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::isExecutable (const String &path)
 Tests if a file is executable.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::canRead (const String &path)
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::canWrite (const String &path)
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::isLink (const String &path)
 Tests if a file is a symbolic link.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::isDirectory (const String &path)
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::changeDirectory (const String &path)
 Change to the given directory.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::makeDirectory (const String &path, int mode=0777)
 Create a directory.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::getFileSize (const String &path, Int64 &size)
 Get the size of the file in bytes.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::removeDirectory (const String &path)
 Remove the given directory.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::removeFile (const String &path)
 Remove the given file.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::getDirectoryContents (const String &path, StringArray &dirEntries)
 Get the names of the files (and directories) in the given directory.
 
BLOCXX_COMMON_API bool BLOCXX_NAMESPACE::FileSystem::renameFile (const String &oldFileName, const String &newFileName)
 Rename the given file to the new name.
 
BLOCXX_COMMON_API size_t BLOCXX_NAMESPACE::FileSystem::read (const FileHandle &hdl, void *bfr, size_t numberOfBytes, Int64 offset=-1L)
 Read data from file.
 
BLOCXX_COMMON_API size_t BLOCXX_NAMESPACE::FileSystem::write (FileHandle hdl, const void *bfr, size_t numberOfBytes, Int64 offset=-1L)
 Write data to a file.
 
BLOCXX_COMMON_API Int64 BLOCXX_NAMESPACE::FileSystem::seek (const FileHandle &hdl, Int64 offset, int whence)
 Seek to a given offset within the file.
 
BLOCXX_COMMON_API Int64 BLOCXX_NAMESPACE::FileSystem::tell (const FileHandle &hdl)
 
BLOCXX_COMMON_API UInt64 BLOCXX_NAMESPACE::FileSystem::fileSize (FileHandle fh)
 Get the size of a file from the file handle.
 
BLOCXX_COMMON_API void BLOCXX_NAMESPACE::FileSystem::rewind (const FileHandle &hdl)
 Position the file pointer associated with the given file handle to the beginning of the file.
 
BLOCXX_COMMON_API int BLOCXX_NAMESPACE::FileSystem::close (const FileHandle &hdl)
 Close file handle.
 
BLOCXX_COMMON_API int BLOCXX_NAMESPACE::FileSystem::flush (FileHandle &hdl)
 Flush any buffered data to the file if buffering supported.
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::getFileContents (const String &filename)
 Read and return the contents of a text file.
 
BLOCXX_COMMON_API StringArray BLOCXX_NAMESPACE::FileSystem::getFileLines (const String &filename)
 Read and return the lines of a test file.
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::readSymbolicLink (const String &path)
 Read the value of a symbolic link.
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::Path::realPath (const String &path)
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::Path::dirname (const String &filename)
 Take a string that contains a pathname, and return a string that is a pathname of the parent directory of that file.
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::Path::basename (const String &filename)
 Take a string that contains a pathname, and return a string that is the filename with the path removed.
 
BLOCXX_COMMON_API String BLOCXX_NAMESPACE::FileSystem::Path::getCurrentWorkingDirectory ()
 Get the process's current working directory.
 

Variables

FileSystemMockObject_t BLOCXX_NAMESPACE::FileSystem::g_fileSystemMockObject = { 0, {0, PTHREAD_MUTEX_INITIALIZER} }
 
GlobalString BLOCXX_NAMESPACE::FileSystem::COMPONENT_NAME = { "blocxx", 0, {0, PTHREAD_MUTEX_INITIALIZER} }
 

Macro Definition Documentation

◆ _ACCESS

#define _ACCESS   ::access
Author
Jon Carey
Dan Nuffer
Kevin S. Van Horn
Anton Afanasiev - Win32 porting

Definition at line 207 of file PosixFileSystem.cpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::canRead(), BLOCXX_NAMESPACE::FileSystem::canWrite(), BLOCXX_NAMESPACE::FileSystem::exists(), and BLOCXX_NAMESPACE::FileSystem::isExecutable().

◆ _CHDIR

#define _CHDIR   chdir

Definition at line 208 of file PosixFileSystem.cpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::changeDirectory().

◆ _MKDIR

#define _MKDIR ( a,
b )
Value:
mkdir((a),(b))

Definition at line 209 of file PosixFileSystem.cpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::makeDirectory().

◆ _RMDIR

#define _RMDIR   rmdir

Definition at line 210 of file PosixFileSystem.cpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::removeDirectory().

◆ _UNLINK

#define _UNLINK   unlink

Definition at line 211 of file PosixFileSystem.cpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::removeFile().