ui-utilcpp 1.10.4
UI::Util::File Class Reference

File representation. More...

#include <File.hpp>

Inheritance diagram for UI::Util::File:
Inheritance graph
Collaboration diagram for UI::Util::File:
Collaboration graph

Public Member Functions

 File (std::string const &name, int flags=O_CREAT|O_WRONLY, mode_t mode=S_IRUSR|S_IWUSR, bool closeFd=true)
 Constructor.
 File (int fd, bool closeFd=false)
 Constructor from file descriptor.
std::string const & getName () const
 Get file name. This will always deliver en empty string if constructed from fd.
Public Member Functions inherited from UI::Util::FileDescriptor
 FileDescriptor (int fd=-1, bool closeFd=false)
 Constructor from file descriptor.
virtual ~FileDescriptor ()
 Destructor.
virtual std::streamsize read (void *const buf, std::streamsize count)
 C++ like virtual read method.
virtual std::streamsize write (void const *const buf, std::streamsize count)
 C++ like virtual erite method.
int getFd () const
 Get file descriptor.

Additional Inherited Members

Public Types inherited from UI::Util::FileDescriptor
enum  ErrorCode {
  OpenErr_ = 1 , ReadErr_ , WriteErr_ , LockErr_ ,
  UnlockErr_ , BindErr_ , ConnectErr_ , UnblockErr_ ,
  ListenErr_ , ShutdownErr_
}
 Error codes for exceptions.
typedef CodeException< ErrorCodeException
 Exceptions for this class.
Static Public Member Functions inherited from UI::Util::FileDescriptor
static void fdClose (int const &fd, std::string const &id, bool const &doClose=true)
 Helper to close file descriptors from destructors.
Protected Member Functions inherited from UI::Util::FileDescriptor
void init (int fd, bool closeFd=false)
 To be called in a constructor.
Protected Attributes inherited from UI::Util::FileDescriptor
int fd_
 The file descriptor that is managed.

Detailed Description

File representation.

See also
FileDescriptor, fcntl(2), open(2), close(2)

Constructor & Destructor Documentation

◆ File() [1/2]

UI::Util::File::File ( std::string const & name,
int flags = O_CREAT | O_WRONLY,
mode_t mode = S_IRUSR | S_IWUSR,
bool closeFd = true )

Constructor.

Parameters
namePath to the file to open
flagsAs in open(2)
modeAs in open(2)
closeFdWhether to call close(2) in destructor
See also
open(2)

This constructor takes a file name, will try to open the file using open(2). Arguments to open(2) can be given optionally, and have reasonable defaults.

OPEN_ERR will be thrown if the file could not be created via open(2).

References UI::Util::FileDescriptor::init().

Referenced by UI::Util::BSDFileMutex::BSDFileMutex(), UI::Util::BSDFileMutex::BSDFileMutex(), UI::Util::PosixFileMutex::PosixFileMutex(), and UI::Util::PosixFileMutex::PosixFileMutex().

◆ File() [2/2]

UI::Util::File::File ( int fd,
bool closeFd = false )

Constructor from file descriptor.

Parameters
fdAlready opened file descriptor
closeFdWhether to call close(2) in destructor

This constructor takes an already opened file descriptor.

References UI::Util::FileDescriptor::FileDescriptor().


The documentation for this class was generated from the following files: