2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Ux::File Class Reference
[C++ Wrapper for Standard UNIX Functions]

Inheritance diagram for Ux::File:

Ux::Base Ux::Dir Ux::PosixShm Ux::Socket Ux::Terminal Ux::Pty List of all members.

Detailed Description

Definition at line 37 of file uxfile.hpp.

Public Member Functions

 File (int f=-1, const char *p=NULL, ssize_t s=-1)
 File (const char *p, ssize_t s=-1)
void set (int f=-1, char *p=NULL, ssize_t s=-1)
void set (char *p, ssize_t s=-1)
ssize_t get_size (void) const
int get_fd (void) const
 operator const char * ()
void alloc (ssize_t n=-1)
void free (void)
size_t get_max_name (const char *path="/")
int access (int what, bool want_throw=true)
void chmod (mode_t mode)
void chown (uid_t uid, gid_t gid)
void close (void)
File dup (void)
File dup2 (int fd2)
int fcntl (int op,...)
void fsync (int op=O_SYNC)
void lchown (uid_t uid, gid_t gid)
void link (const char *newpath)
void lockf (int op, off_t len)
void lstat (struct stat *buf)
void mkfifo (mode_t perms=PERM_FILE)
void mknod (mode_t mode, dev_t dev)
void mkstemp (void)
void open (int flags, mode_t perms=PERM_FILE)
long pathconf (int name, long default_val=-1)
ssize_t read (void *buf, size_t nbytes, off_t offset=-1)
ssize_t readlink (char *buf, size_t bufsize)
ssize_t readv (const struct iovec *iov, int iovcnt)
void rename (const char *newpath)
off_t seek (off_t pos, int whence)
void stat (struct stat *buf)
void statvfs (struct STATVFS_NAME *buf)
void symlink (const char *newpath)
void truncate (off_t length)
void unlink (void)
void utime (const struct utimbuf *timbuf)
ssize_t writev (const struct iovec *iov, int iovcnt)
ssize_t write (const void *buf, size_t nbytes, off_t offset=-1)

Static Public Member Functions

void pipe (File pf[2])
int poll (struct pollfd fdinfo[], nfds_t nfds, int timeout=-1)
int pselect (int nfds, fd_set *readset, fd_set *writeset=NULL, fd_set *errorset=NULL, const struct timespec *timeout=NULL, const sigset_t *sigmask=NULL)
int select (int nfds, fd_set *readset, fd_set *writeset=NULL, fd_set *errorset=NULL, struct timeval *timeout=NULL)
void sync (void)

Protected Attributes

int fd
const char * path
ssize_t size


Constructor & Destructor Documentation

Ux::File::File int  f = -1,
const char *  p = NULL,
ssize_t  s = -1
[inline]
 

Definition at line 44 of file uxfile.hpp.

Referenced by dup(), dup2(), and get_max_name().

Ux::File::File const char *  p,
ssize_t  s = -1
[inline]
 

Definition at line 47 of file uxfile.hpp.


Member Function Documentation

int File::access int  what,
bool  want_throw = true
 

Calls access.

Definition at line 59 of file uxfile.cpp.

References errno, and path.

void File::alloc ssize_t  n = -1  ) 
 

Calls malloc to allocate the path.

Definition at line 25 of file uxfile.cpp.

References errno, get_max_name(), path, and size.

void File::chmod mode_t  mode  ) 
 

Calls chmod or fchmod.

Definition at line 71 of file uxfile.cpp.

References errno, fd, and path.

void File::chown uid_t  uid,
gid_t  gid
 

Calls chown or fchown.

Definition at line 86 of file uxfile.cpp.

References errno, fd, and path.

void File::close void   ) 
 

Calls close.

Definition at line 101 of file uxfile.cpp.

References errno, and fd.

File File::dup void   ) 
 

Calls dup.

Definition at line 110 of file uxfile.cpp.

References errno, fd, and File().

File File::dup2 int  fd2  ) 
 

Calls dup2.

Definition at line 122 of file uxfile.cpp.

References errno, fd, and File().

int File::fcntl int  op,
... 
 

Calls fcntl. Works only if the single optional argument is an int or pointer.

Definition at line 132 of file uxfile.cpp.

References errno, and fd.

void File::free void   ) 
 

Calls free to free the path.

Definition at line 39 of file uxfile.cpp.

References path, and size.

void File::fsync int  op = O_SYNC  ) 
 

Calls fsync or fdatasync.

Definition at line 147 of file uxfile.cpp.

References errno, fd, and O_SYNC.

int Ux::File::get_fd void   )  const [inline]
 

Definition at line 64 of file uxfile.hpp.

size_t File::get_max_name const char *  p = "/"  ) 
 

Calls pathconf to get _PC_PATH_MAX.

Definition at line 49 of file uxfile.cpp.

References File().

Referenced by alloc().

ssize_t Ux::File::get_size void   )  const [inline]
 

Definition at line 62 of file uxfile.hpp.

Referenced by Ux::Process::getcwd().

void File::lchown uid_t  uid,
gid_t  gid
 

Calls lchown.

Definition at line 169 of file uxfile.cpp.

References errno, and path.

void File::link const char *  newpath  ) 
 

Calls link.

Definition at line 178 of file uxfile.cpp.

References errno, and path.

void File::lockf int  op,
off_t  len
 

Calls lockf.

Definition at line 187 of file uxfile.cpp.

References errno, and fd.

void File::lstat struct stat *  buf  ) 
 

Calls lstat.

Definition at line 196 of file uxfile.cpp.

References errno, and path.

void File::mkfifo mode_t  perms = PERM_FILE  ) 
 

Calls mkfifo.

Definition at line 205 of file uxfile.cpp.

References errno, and path.

void File::mknod mode_t  perms,
dev_t  dev
 

Calls mknod.

Definition at line 214 of file uxfile.cpp.

References errno, and path.

void File::mkstemp void   ) 
 

Calls mkstemp.

Definition at line 223 of file uxfile.cpp.

References errno, fd, and path.

void File::open int  flags,
mode_t  perms = PERM_FILE
 

Calls open.

Definition at line 233 of file uxfile.cpp.

References errno, fd, and path.

Ux::File::operator const char *  )  [inline]
 

Definition at line 66 of file uxfile.hpp.

long File::pathconf int  name,
long  default_val = -1
 

Calls pathconf or fpathconf, with a default value to be used if the value is unspecified.

Definition at line 242 of file uxfile.cpp.

References errno, fd, and path.

void File::pipe File  pf[2]  )  [static]
 

Calls pipe.

Definition at line 263 of file uxfile.cpp.

References errno, and set().

int Ux::File::poll struct pollfd  fdinfo[],
nfds_t  nfds,
int  timeout = -1
[static]
 

int Ux::File::pselect int  nfds,
fd_set *  readset,
fd_set *  writeset = NULL,
fd_set *  errorset = NULL,
const struct timespec *  timeout = NULL,
const sigset_t *  sigmask = NULL
[static]
 

ssize_t File::read void *  buf,
size_t  nbytes,
off_t  offset = -1
 

Calls read or pread.

Definition at line 300 of file uxfile.cpp.

References errno, and fd.

ssize_t File::readlink char *  buf,
size_t  bufsize
 

Calls readlink.

Definition at line 316 of file uxfile.cpp.

References errno, and path.

ssize_t File::readv const struct iovec *  iov,
int  iovcnt
 

Calls readv.

Definition at line 328 of file uxfile.cpp.

References errno, and fd.

void File::rename const char *  newpath  ) 
 

Calls rename.

Definition at line 340 of file uxfile.cpp.

References errno, and path.

off_t File::seek off_t  pos,
int  whence
 

Calls lseek.

Definition at line 349 of file uxfile.cpp.

References errno, and fd.

int Ux::File::select int  nfds,
fd_set *  readset,
fd_set *  writeset = NULL,
fd_set *  errorset = NULL,
struct timeval *  timeout = NULL
[static]
 

void Ux::File::set char *  p,
ssize_t  s = -1
[inline]
 

Definition at line 56 of file uxfile.hpp.

void Ux::File::set int  f = -1,
char *  p = NULL,
ssize_t  s = -1
[inline]
 

Definition at line 50 of file uxfile.hpp.

Referenced by pipe(), and Ux::Socket::socketpair().

void File::stat struct stat *  buf  ) 
 

Calls stat or fstat.

Definition at line 373 of file uxfile.cpp.

References errno, fd, and path.

void File::statvfs struct STATVFS_NAME *  buf  ) 
 

Calls statvfs or fstatvfs, or whatever nonportable substitute has been defined.

Definition at line 388 of file uxfile.cpp.

References errno, fd, and path.

void File::symlink const char *  newpath  ) 
 

Calls symlink.

Definition at line 403 of file uxfile.cpp.

References errno, and path.

void File::sync void   )  [static]
 

Calls sync.

Definition at line 412 of file uxfile.cpp.

void File::truncate off_t  length  ) 
 

Calls truncate or ftruncate.

Definition at line 420 of file uxfile.cpp.

References errno, fd, and path.

void File::unlink void   ) 
 

Calls unlink.

Definition at line 435 of file uxfile.cpp.

References errno, and path.

void File::utime const struct utimbuf *  timbuf  ) 
 

Calls utime.

Definition at line 444 of file uxfile.cpp.

References errno, and path.

ssize_t File::write const void *  buf,
size_t  nbytes,
off_t  offset = -1
 

Calls write or pwrite.

Definition at line 453 of file uxfile.cpp.

References errno, and fd.

ssize_t File::writev const struct iovec *  iov,
int  iovcnt
 

Calls writev.

Definition at line 469 of file uxfile.cpp.

References errno, and fd.


Member Data Documentation

int Ux::File::fd [protected]
 

Definition at line 39 of file uxfile.hpp.

Referenced by Ux::Socket::accept(), Ux::Socket::bind(), chmod(), chown(), close(), Ux::Socket::connect(), dup(), dup2(), fcntl(), fsync(), Ux::Socket::getpeername(), Ux::Socket::getsockname(), Ux::Socket::getsockopt(), Ux::Pty::grantpt(), Ux::Terminal::isatty(), Ux::Socket::listen(), lockf(), mkstemp(), Ux::PosixShm::mmap(), Ux::PosixShm::open(), open(), pathconf(), Ux::Pty::posix_openpt(), Ux::Pty::ptsname(), read(), readv(), Ux::Socket::recv(), Ux::Socket::recvfrom(), Ux::Socket::recvmsg(), seek(), Ux::Socket::send(), Ux::Socket::sendmsg(), Ux::Socket::sendto(), Ux::Socket::setsockopt(), Ux::Socket::shutdown(), Ux::Socket::sockatmark(), Ux::Socket::socket(), stat(), statvfs(), Ux::Terminal::tcdrain(), Ux::Terminal::tcflow(), Ux::Terminal::tcflush(), Ux::Terminal::tcgetattr(), Ux::Terminal::tcgetpgrp(), Ux::Terminal::tcgetsid(), Ux::Terminal::tcsendbreak(), Ux::Terminal::tcsetattr(), Ux::Terminal::tcsetpgrp(), truncate(), Ux::Terminal::ttyname(), Ux::Pty::unlockpt(), write(), and writev().

const char* Ux::File::path [protected]
 

Definition at line 40 of file uxfile.hpp.

Referenced by access(), alloc(), chmod(), chown(), free(), lchown(), link(), lstat(), Ux::Dir::mkdir(), mkfifo(), mknod(), mkstemp(), open(), pathconf(), readlink(), rename(), Ux::Dir::rmdir(), stat(), statvfs(), symlink(), truncate(), unlink(), and utime().

ssize_t Ux::File::size [protected]
 

Definition at line 41 of file uxfile.hpp.

Referenced by alloc(), and free().


The documentation for this class was generated from the following files:
Generated on Fri Apr 23 10:57:16 2004 for AUP2 Example Source by doxygen 1.3.1