113 OpenOptions opts = ModeDefault
125 OpenOptions opts = ModeDefault
253 const PTime & accessTime = 0
257 const PTime & accessTime,
258 const PTime & modTime
267 const PTime & accessTime = 0
270 const PTime & accessTime,
271 const PTime & modTime
439 OpenOptions opts = ModeDefault
452 PFileInfo::Permissions permissions
465 OpenOptions opts = ModeDefault
479 PFileInfo::Permissions permissions
563 PFileInfo::Permissions permissions
571 PFileInfo::Permissions permissions
595 off_t maxSize = 1000000000,
680 #include "msos/ptlib/file.h"
682 #include "unix/ptlib/file.h"
687 #endif // PTLIB_FILE_H
off_t m_maxSize
Size in bytes which triggers a rotation, default zero disables.
Definition: file.h:659
virtual PBoolean Close()
Close the file channel.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the file channel.
const PFilePath & GetFilePath() const
Get the full path name of the file.
static bool Copy(const PFilePath &oldname, const PFilePath &newname, bool force=false, bool recurse=false)
Make a copy of the specified file.
This class represents a disk file.
Definition: file.h:57
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
static bool Move(const PFilePath &oldname, const PFilePath &newname, bool force=false, bool recurse=false)
Move the specified file.
bool IsEndOfFile() const
Determine if the current file position is at the end of the file.
static bool Rename(const PFilePath &oldname, const PString &newname, bool force=false)
Change the specified files name.
bool Rotate(PFile &activeFile, bool force=false, const PTime &now=PTime())
Execute a rotation.
This class defines an absolute time and date.
Definition: ptime.h:49
PDirectory m_directory
Destination directory for rotated file, default to same s log file.
Definition: file.h:654
virtual off_t GetLength() const
Get the current size of the file.
Information on how to rotate files.
Definition: file.h:587
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
static const PString & DefaultTimestamp()
virtual void OnCloseFile(PFile &file, const PFilePath &rotatedTo)
Callback when a rotation of an open file is about to be performed.
File can be both read and written.
Definition: file.h:77
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
P_DECLARE_STREAMABLE_ENUM(Period, SizeOnly, Hourly, Daily, Weekly, Monthly)
virtual void OnMessage(bool error, const PString &msg)
Callback when have a message on thte rotation.
virtual PBoolean SetPosition(off_t pos, FilePositionOrigin origin=Start)
Set the current active position in the file for the next read or write operation. ...
virtual bool OnOpenFile(PFile &file)
Callback to open the file.
File can be read but not written.
Definition: file.h:75
unsigned m_maxFileCount
When this many files have been rotated, oldest is deleted.
Definition: file.h:662
PString m_timestamp
Time template for rotated file, default "_yyyy_MM_dd_hh_mm".
Definition: file.h:656
PFilePath m_path
The fully qualified path name for the file.
Definition: file.h:674
bool Exists() const
Check for file existance.
static bool Touch(const PFilePath &name, const PTime &accessTime=0)
Set access & modification times for file.
Class to represent a directory in the operating system file system.
Definition: pdirect.h:173
Set position relative to current file position.
Definition: file.h:502
virtual bool InternalOpen(OpenMode mode, OpenOptions opts, PFileInfo::Permissions permissions)
P_DECLARE_BITWISE_ENUM_EX(OpenOptions, 7,(NoOptions, MustExist, Create, Truncate, Exclusive, Temporary, DenySharedRead, DenySharedWrite), ModeDefault=-1)
When a file is opened, a number of options may be associated with the open file.
off_t m_freeDisk
Minimum free space for the disk. Negative is percentage, positive is bytes.
Definition: file.h:660
PFilePathString m_suffix
File name suffix, default ".log".
Definition: file.h:658
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the file channel.
PTime m_lastTime
Definition: file.h:665
Abstract class defining I/O channel semantics.
Definition: channel.h:103
FilePositionOrigin
Options for the origin in setting the file position.
Definition: file.h:500
bool m_removeOnClose
File is to be removed when closed.
Definition: file.h:675
File can be written but not read.
Definition: file.h:76
virtual off_t GetPosition() const
Get the current active position in the file for the next read or write operation. ...
bool PBoolean
Definition: object.h:174
bool CanRotate() const
Inidcate that the RotateInfo is configured so that rotations can be made via the Rotate() function...
PFile()
Create a file object but do not open it.
The character string class.
Definition: pstring.h:108
void SetFilePath(const PString &path)
Set the full path name of the file.
PTimeInterval m_maxFileAge
Rotated files older than this are deleted.
Definition: file.h:663
PFilePathString m_prefix
File name prefix, default PProcess::GetName()
Definition: file.h:655
Base string type for a file path.
Definition: filepath.h:44
Period m_period
Rotate on the peroid regardless of size.
Definition: file.h:661
int m_timeZone
TIme zone for output and rotated file names.
Definition: file.h:657
Set position relative to end of file.
Definition: file.h:503
static bool GetInfo(const PFilePath &name, PFileInfo &info)
Get information (eg protection, timestamps) on the specified file.
static const PString & Empty()
Return an empty string.
static bool Remove(const PFilePath &name, bool force=false)
Delete the specified file.
static bool SetPermissions(const PFilePath &name, PFileInfo::Permissions permissions)
Set permissions on the specified file.
RotateInfo & operator=(const RotateInfo &other)
static bool Access(const PFilePath &name, OpenMode mode)
Check for file access modes.
RotateInfo(const PDirectory &dir=PDirectory(), const PString &prefix=PString::Empty(), const PString &suffix=PString::Empty(), const PString ×tamp=DefaultTimestamp(), off_t maxSize=1000000000, off_t minFree=-10)
~PFile()
Close the file on destruction.
virtual PString GetName() const
Get the platform and I/O channel type name of the channel.
Set position relative to start of file.
Definition: file.h:501
virtual PBoolean SetLength(off_t len)
Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter.
virtual ~RotateInfo()
Definition: file.h:600
Class containing the system information on a file path.
Definition: pdirect.h:65
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
Comparison Compare(const PObject &obj) const
Determine the relative rank of the two objects.
OpenMode
When a file is opened, it may restrict the access available to operations on the object instance...
Definition: file.h:74
bool Open(OpenMode mode=ReadWrite, OpenOptions opts=ModeDefault)
Open the current file in the specified mode and with the specified options.