The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileDesc Class Reference

#include <filemgr.h>

+ Collaboration diagram for FileDesc:

Public Member Functions

int getFd ()
 
long read (void *buf, long count)
 
long seek (long offset, int whence)
 
long write (const void *buf, long count)
 

Public Attributes

int mode
 
char * path
 
int perms
 
bool tryDowngrade
 

Private Member Functions

 FileDesc (FileMgr *parent, const char *path, int mode, int perms, bool tryDowngrade)
 
virtual ~FileDesc ()
 

Private Attributes

int fd
 
FileDesc * next
 
long offset
 
FileMgr * parent
 

Friends

class FileMgr
 

Detailed Description

This class represents one file. It works with the FileMgr object.

Definition at line 215 of file filemgr.h.

Constructor & Destructor Documentation

FileDesc::FileDesc ( FileMgr *  parent,
const char *  path,
int  mode,
int  perms,
bool  tryDowngrade 
)
private

Definition at line 122 of file filemgr.cpp.

122  {
123  this->parent = parent;
124  this->path = 0;
125  stdstr(&this->path, path);
126  this->mode = mode;
127  this->perms = perms;
128  this->tryDowngrade = tryDowngrade;
129  offset = 0;
130  fd = -77;
131 }
int fd
Definition: filemgr.h:220
int perms
Definition: filemgr.h:251
int mode
Definition: filemgr.h:248
char * path
Definition: filemgr.h:245
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
long offset
Definition: filemgr.h:219
FileMgr * parent
Definition: filemgr.h:221
bool tryDowngrade
Definition: filemgr.h:254
FileDesc::~FileDesc ( )
privatevirtual

Definition at line 134 of file filemgr.cpp.

134  {
135  if (fd > 0)
137 
138  if (path)
139  delete [] path;
140 }
int fd
Definition: filemgr.h:220
static void closeFile(int fd)
Definition: filemgr.cpp:491
char * path
Definition: filemgr.h:245

Member Function Documentation

int FileDesc::getFd ( )
inline
Returns
File handle. NOTE: magic file descriptor -77 = closed to avoid os limits

Definition at line 231 of file filemgr.h.

231  {
232  if (fd == -77)
233  fd = parent->sysOpen(this);
234 // if ((fd < -1) && (fd != -77)) // kludge to handle ce
235 // return 777;
236  return fd;
237  }
int fd
Definition: filemgr.h:220
int sysOpen(FileDesc *file)
Definition: filemgr.cpp:209
FileMgr * parent
Definition: filemgr.h:221
long FileDesc::read ( void *  buf,
long  count 
)

Definition at line 148 of file filemgr.cpp.

148  {
149  return ::read(getFd(), buf, count);
150 }
int getFd()
Definition: filemgr.h:231
long FileDesc::seek ( long  offset,
int  whence 
)

Definition at line 143 of file filemgr.cpp.

143  {
144  return lseek(getFd(), offset, whence);
145 }
int getFd()
Definition: filemgr.h:231
long offset
Definition: filemgr.h:219
long FileDesc::write ( const void *  buf,
long  count 
)

Definition at line 153 of file filemgr.cpp.

153  {
154  return FileMgr::write(getFd(), buf, count);
155 }
int getFd()
Definition: filemgr.h:231
static long write(int fd, const void *buf, long count)
Definition: filemgr.cpp:115

Friends And Related Function Documentation

friend class FileMgr
friend

Definition at line 217 of file filemgr.h.

Member Data Documentation

int FileDesc::fd
private

Definition at line 220 of file filemgr.h.

int FileDesc::mode

File access mode.

Definition at line 248 of file filemgr.h.

FileDesc* FileDesc::next
private

Definition at line 222 of file filemgr.h.

long FileDesc::offset
private

Definition at line 219 of file filemgr.h.

FileMgr* FileDesc::parent
private

Definition at line 221 of file filemgr.h.

char* FileDesc::path

Path to file.

Definition at line 245 of file filemgr.h.

int FileDesc::perms

File permissions.

Definition at line 251 of file filemgr.h.

bool FileDesc::tryDowngrade

Definition at line 254 of file filemgr.h.


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