How should a file be opened/created? Should it be locked? More...

#include <File.h>

Collaboration diagram for FileOpeningConfig:

Public Member Functions

FileOpeningConfiglocked (unsigned int attempts=5)
 protect concurrent accesses by attempting to obtain an appropriate lock More...
FileOpeningConfigcreatedIfMissing ()
 when opening a file for writing, create it if it does not exist More...
FileOpeningConfigopenedByRoot ()
 enter_suid() to open the file; leaves suid ASAP after that More...

Static Public Member Functions

static FileOpeningConfig ReadOnly ()
static FileOpeningConfig ReadWrite ()

Private Attributes

mode_t creationMask = 0
 umask() parameter; the default is S_IWGRP|S_IWOTH More...
int openFlags = 0
 opening flags; 2nd open(2) parameter More...
mode_t openMode = 0644
 access mode; 3rd open(2) parameter More...
int flockMode = LOCK_UN
 2nd flock(2) parameter More...
unsigned int lockAttempts = 0
 pause before each lock retry More...
bool openByRoot = false

Static Private Attributes

static const unsigned int RetryGapUsec = 500000


class File

Detailed Description

Definition at line 19 of file File.h.

Member Function Documentation

◆ createdIfMissing()

FileOpeningConfig & FileOpeningConfig::createdIfMissing ( )

Definition at line 89 of file

References creationMask, Must, and openFlags.

◆ locked()

FileOpeningConfig & FileOpeningConfig::locked ( unsigned int  attempts = 5)

Definition at line 81 of file

References lockAttempts.

◆ openedByRoot()

FileOpeningConfig& FileOpeningConfig::openedByRoot ( )

Definition at line 34 of file File.h.

References openByRoot.

◆ ReadOnly()

FileOpeningConfig FileOpeningConfig::ReadOnly ( )

Definition at line 31 of file

References flockMode, and openFlags.

Referenced by Instance::Other(), and Instance::ThrowIfAlreadyRunning().

◆ ReadWrite()

FileOpeningConfig FileOpeningConfig::ReadWrite ( )

Definition at line 56 of file

References flockMode, and openFlags.

Referenced by Instance::WriteOurPid().

Friends And Related Function Documentation

◆ File

friend class File

Definition at line 39 of file File.h.

Member Data Documentation

◆ creationMask

mode_t FileOpeningConfig::creationMask = 0

Definition at line 47 of file File.h.

Referenced by createdIfMissing(), and File::open().

◆ flockMode

int FileOpeningConfig::flockMode = LOCK_UN

Definition at line 58 of file File.h.

Referenced by File::lockOnce(), ReadOnly(), and ReadWrite().

◆ lockAttempts

unsigned int FileOpeningConfig::lockAttempts = 0

how many times to try locking

Definition at line 61 of file File.h.

Referenced by File::lock(), and locked().

◆ openByRoot

bool FileOpeningConfig::openByRoot = false

Definition at line 62 of file File.h.

Referenced by openedByRoot().

◆ openFlags

int FileOpeningConfig::openFlags = 0

Definition at line 48 of file File.h.

Referenced by createdIfMissing(), File::open(), ReadOnly(), and ReadWrite().

◆ openMode

mode_t FileOpeningConfig::openMode = 0644

Definition at line 49 of file File.h.

Referenced by File::open().

◆ RetryGapUsec

const unsigned int FileOpeningConfig::RetryGapUsec = 500000

Definition at line 60 of file File.h.

Referenced by File::lock().

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






Web Site Translations