Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VsnetDownload::Client::File Class Reference

#include <vsnet_notify.h>

Inheritance diagram for VsnetDownload::Client::File:
VsnetDownload::Client::Item VsnetDownload::Client::NoteFile

Public Member Functions

 File (SOCKETALT sock, const std::string &filename, std::string localbasepath, VSFileSystem::VSFileType ft, NotifyPtr notify=NotifyPtr())
 
 File (const std::string &destfile, SOCKETALT sock, const std::string &filename, std::string localbasepath, VSFileSystem::VSFileType ft, NotifyPtr notify=NotifyPtr())
 
virtual ~File ()
 
- Public Member Functions inherited from VsnetDownload::Client::Item
 Item (SOCKETALT sock, const std::string &filename, VSFileSystem::VSFileType=VSFileSystem::UnknownFile, NotifyPtr notify=NotifyPtr())
 
virtual ~Item ()
 
State state () const
 
VSError error () const
 
void changeState (State s)
 
void changeState (State s, VSError e)
 
void setFileType (VSFileSystem::VSFileType ft)
 
VSFileSystem::VSFileType getFileType ()
 
void setSize (int len)
 
void append (unsigned char *buffer, int bufsize)
 
const std::string & getFilename () const
 
SOCKETALT getSock () const
 
int get_fd () const
 

Protected Member Functions

virtual void childSetSize (int len)
 
virtual void childAppend (unsigned char *buffer, int bufsize)
 
- Protected Member Functions inherited from VsnetDownload::Client::Item
void protected_replace_notifier (NotifyPtr ptr)
 

Additional Inherited Members

- Protected Attributes inherited from VsnetDownload::Client::Item
VSFileSystem::VSFileType _filetype
 

Detailed Description

Definition at line 215 of file vsnet_notify.h.

Constructor & Destructor Documentation

VsnetDownload::Client::File::File ( SOCKETALT  sock,
const std::string &  filename,
std::string  localbasepath,
VSFileSystem::VSFileType  ft,
NotifyPtr  notify = NotifyPtr() 
)
VsnetDownload::Client::File::File ( const std::string &  destfile,
SOCKETALT  sock,
const std::string &  filename,
std::string  localbasepath,
VSFileSystem::VSFileType  ft,
NotifyPtr  notify = NotifyPtr() 
)
VsnetDownload::Client::File::~File ( )
virtual

Definition at line 165 of file vsnet_notify.cpp.

References VSFileSystem::VSFile::Close().

166 {
167  if (_of) {
168  _of->Close();
169  delete _of;
170  }
171 }

Member Function Documentation

void VsnetDownload::Client::File::childAppend ( unsigned char *  buffer,
int  bufsize 
)
protectedvirtual

Implements VsnetDownload::Client::Item.

Definition at line 188 of file vsnet_notify.cpp.

References bufsize, VSFileSystem::VSFile::Close(), and VSFileSystem::VSFile::Write().

189 {
190  if (_of) {
191  _of->Write( (const char*) buffer, bufsize );
192  _offset += bufsize;
193  if (_offset >= _len) {
194  _of->Close();
195  delete _of;
196  _of = NULL;
197  }
198  }
199 }
void VsnetDownload::Client::File::childSetSize ( int  len)
protectedvirtual

Implements VsnetDownload::Client::Item.

Definition at line 173 of file vsnet_notify.cpp.

References VsnetDownload::Client::Item::_filetype, VSFileSystem::Ok, and VSFileSystem::VSFile::OpenCreateWrite().

174 {
175  //string filename = _localbasepath + "/" + getFilename();
176  //string filename = getFilename();
177 
178  _of = new VSFileSystem::VSFile;
179  VSFileSystem::VSError err = _of->OpenCreateWrite( _destfile.c_str(), this->_filetype );
180  if (err > Ok) {
181  delete _of;
182  _of = NULL;
183  } else {
184  _len = len;
185  }
186 }

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