3
MediaTomb - http://www.mediatomb.cc/
5
fd_io_handler.h - this file is part of MediaTomb.
7
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
10
Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
11
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
Leonhard Wimmer <leo@mediatomb.cc>
14
MediaTomb is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License version 2
16
as published by the Free Software Foundation.
18
MediaTomb is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
version 2 along with MediaTomb; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
30
/// \file fd_io_handler.h
31
/// \brief Definition of the FDIOHandler class.
32
#ifndef __FD_IO_HANDLER_H__
33
#define __FD_IO_HANDLER_H__
36
#include "io_handler.h"
38
/// \brief Allows the web server to read from a file, operation is blocking.
39
class FDIOHandler : public IOHandler
42
/// \brief Name of the file.
45
/// \brief Handle of the file.
48
zmm::Ref<IOHandler> other;
49
zmm::Ref<zmm::Array<zmm::Object> > reference_list;
51
/// \brief Sets the filename to work with.
52
FDIOHandler(zmm::String filename);
54
/// \brief Sets an aleady opened file descriptor to work with, call to
55
/// open() will be ignored.
58
void addReference(zmm::Ref<zmm::Object> reference);
59
void closeOther(zmm::Ref<IOHandler> other);
61
/// \brief Opens file for reading (writing is not supported)
62
virtual void open(IN enum UpnpOpenFileMode mode);
64
/// \brief Reads a previously opened file sequentially.
65
/// \param buf Data from the file will be copied into this buffer.
66
/// \param length Number of bytes to be copied into the buffer.
67
virtual int read(OUT char *buf, IN size_t length);
69
/// \brief Writes to a previously opened file.
70
/// \param buf Data from the buffer will be written to the file.
71
/// \param length Number of bytes to be written from the buffer.
72
/// \return number of bytes written.
73
virtual int write(OUT char *buf, IN size_t length);
75
/// \brief Performs seek on an open file.
76
/// \param offset Number of bytes to move in the file. For seeking forwards
77
/// positive values are used, for seeking backwards - negative. Offset must
78
/// be positive if origin is set to SEEK_SET
79
/// \param whence The position to move relative to. SEEK_CUR to move relative
80
/// to current position, SEEK_END to move relative to the end of file,
81
/// SEEK_SET to specify an absolute offset.
82
virtual void seek(IN off_t offset, IN int whence);
84
/// \brief Close a previously opened file.
89
#endif // __FD_IO_HANDLER_H__