µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::posix::file_impl Class Referenceabstract

#include <file.h>

+ Inheritance diagram for os::posix::file_impl:

Public Member Functions

Constructors & Destructor
 file_impl (file_system &fs)
 
virtual ~file_impl () override
 
Public Member Functions
virtual int do_ftruncate (off_t length)=0
 
virtual int do_fsync (void)=0
 
class file_systemget_file_system (void)
 
Public Member Functions
virtual void do_deallocate (void)
 
virtual bool do_is_opened (void)=0
 
virtual bool do_is_connected (void)
 
virtual ssize_t do_read (void *buf, std::size_t nbyte)=0
 
virtual ssize_t do_write (const void *buf, std::size_t nbyte)=0
 
virtual ssize_t do_writev (const iovec *iov, int iovcnt)
 
virtual int do_vfcntl (int cmd, std::va_list args)
 
virtual int do_isatty (void)
 
virtual int do_fstat (struct stat *buf)
 
virtual off_t do_lseek (off_t offset, int whence)=0
 
virtual int do_close (void)=0
 
off_t offset (void)
 
void offset (off_t offset)
 

Detailed Description

Definition at line 169 of file file.h.

Constructor & Destructor Documentation

◆ file_impl()

os::posix::file_impl::file_impl ( file_system fs)

Definition at line 118 of file file.cpp.

118 : file_system_ (fs)
119 {
120#if defined(OS_TRACE_POSIX_IO_FILE)
121 trace::printf ("file_impl::%s()=%p\n", __func__, this);
122#endif
123 }
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::trace::printf().

◆ ~file_impl()

os::posix::file_impl::~file_impl ( )
overridevirtual

Definition at line 125 of file file.cpp.

126 {
127#if defined(OS_TRACE_POSIX_IO_FILE)
128 trace::printf ("file_impl::%s() @%p\n", __func__, this);
129#endif
130 }

References os::trace::printf().

Member Function Documentation

◆ do_close()

virtual int os::posix::io_impl::do_close ( void  )
pure virtualinherited

◆ do_deallocate()

void os::posix::io_impl::do_deallocate ( void  )
virtualinherited

Definition at line 482 of file io.cpp.

483 {
484 return;
485 }

◆ do_fstat()

int os::posix::io_impl::do_fstat ( struct stat buf)
virtualinherited

Definition at line 539 of file io.cpp.

540 {
541 errno = ENOSYS; // Not implemented
542 return -1;
543 }

Referenced by os::posix::io::fstat().

◆ do_fsync()

int os::posix::file_impl::do_fsync ( void  )
pure virtual

Definition at line 151 of file file.cpp.

152 {
153 errno = ENOSYS; // Not implemented
154 return -1;
155 }

Referenced by os::posix::file::fsync().

◆ do_ftruncate()

int os::posix::file_impl::do_ftruncate ( off_t  length)
pure virtual

Definition at line 142 of file file.cpp.

143 {
144 errno = ENOSYS; // Not implemented
145 return -1;
146 }

Referenced by os::posix::file::ftruncate().

◆ do_is_connected()

bool os::posix::io_impl::do_is_connected ( void  )
virtualinherited

Definition at line 496 of file io.cpp.

497 {
498 return true;
499 }

◆ do_is_opened()

virtual bool os::posix::io_impl::do_is_opened ( void  )
pure virtualinherited

Implemented in os::posix::device_impl.

Referenced by os::posix::io::is_opened().

◆ do_isatty()

int os::posix::io_impl::do_isatty ( void  )
virtualinherited

Reimplemented in os::posix::tty_impl.

Definition at line 532 of file io.cpp.

533 {
534 errno = ENOTTY; // By default, it is not a TTY.
535 return 0;
536 }

Referenced by os::posix::io::isatty().

◆ do_lseek()

virtual off_t os::posix::io_impl::do_lseek ( off_t  offset,
int  whence 
)
pure virtualinherited

◆ do_read()

virtual ssize_t os::posix::io_impl::do_read ( void *  buf,
std::size_t  nbyte 
)
pure virtualinherited

Implemented in os::posix::block_device_impl.

Referenced by os::posix::io::read().

◆ do_vfcntl()

int os::posix::io_impl::do_vfcntl ( int  cmd,
std::va_list  args 
)
virtualinherited

Definition at line 525 of file io.cpp.

526 {
527 errno = ENOSYS; // Not implemented
528 return -1;
529 }

Referenced by os::posix::io::vfcntl().

◆ do_write()

virtual ssize_t os::posix::io_impl::do_write ( const void *  buf,
std::size_t  nbyte 
)
pure virtualinherited

◆ do_writev()

ssize_t os::posix::io_impl::do_writev ( const iovec iov,
int  iovcnt 
)
virtualinherited

Definition at line 502 of file io.cpp.

503 {
504 ssize_t total = 0;
505
506#pragma GCC diagnostic push
507#if defined(__clang__)
508#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
509#endif
510 const /* struct */ iovec* p = iov;
511 for (int i = 0; i < iovcnt; ++i, ++p)
512 {
513 ssize_t ret = do_write (p->iov_base, p->iov_len);
514 if (ret < 0)
515 {
516 return ret;
517 }
518 total += ret;
519 }
520#pragma GCC diagnostic pop
521 return total;
522 }
virtual ssize_t do_write(const void *buf, std::size_t nbyte)=0
Definition uio.h:40
void * iov_base
Definition uio.h:41
size_t iov_len
Definition uio.h:42

References os::posix::io_impl::do_write(), iovec::iov_base, and iovec::iov_len.

Referenced by os::posix::io::writev().

◆ get_file_system()

file_system & os::posix::file_impl::get_file_system ( void  )
inline

Definition at line 492 of file file.h.

493 {
494 return file_system_;
495 }

Referenced by os::posix::file::get_file_system().

◆ offset() [1/2]

void os::posix::io_impl::offset ( off_t  offset)
inlineinherited

Definition at line 478 of file io.h.

479 {
480 offset_ = offset;
481 }
off_t offset(void)
Definition io.h:472

References os::posix::io_impl::offset().

◆ offset() [2/2]

off_t os::posix::io_impl::offset ( void  )
inlineinherited

Definition at line 472 of file io.h.

473 {
474 return offset_;
475 }

Referenced by os::posix::block_device_partition_impl::configure(), os::posix::block_device_impl::do_lseek(), and os::posix::io_impl::offset().


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