ReactOS 0.4.15-dev-7934-g1dc8d80
fstream_unistd.cpp File Reference
#include <fstream>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
Include dependency graph for fstream_unistd.cpp:

Go to the source code of this file.

Macros

#define O_ACCMODE   (O_RDONLY|O_WRONLY|O_RDWR)
 
#define FSTAT   fstat
 
#define STAT   stat
 
#define LSEEK   lseek
 
#define MMAP   mmap
 
#define OPEN   open
 
#define MAP_FAILED   -1
 

Functions

static _STLP_BEGIN_NAMESPACE ios_base::openmode flag_to_openmode (int mode)
 
static _STLP_MOVE_TO_PRIV_NAMESPACE bool __is_regular_file (_STLP_fd fd)
 
static streamoff __file_size (_STLP_fd fd)
 

Variables

const _STLP_fd INVALID_STLP_FD = -1
 

Macro Definition Documentation

◆ FSTAT

#define FSTAT   fstat

Definition at line 59 of file fstream_unistd.cpp.

◆ LSEEK

#define LSEEK   lseek

Definition at line 61 of file fstream_unistd.cpp.

◆ MAP_FAILED

#define MAP_FAILED   -1

Definition at line 73 of file fstream_unistd.cpp.

◆ MMAP

#define MMAP   mmap

Definition at line 62 of file fstream_unistd.cpp.

◆ O_ACCMODE

#define O_ACCMODE   (O_RDONLY|O_WRONLY|O_RDWR)

Definition at line 53 of file fstream_unistd.cpp.

◆ OPEN

#define OPEN   open

Definition at line 63 of file fstream_unistd.cpp.

◆ STAT

#define STAT   stat

Definition at line 60 of file fstream_unistd.cpp.

Function Documentation

◆ __file_size()

static streamoff __file_size ( _STLP_fd  fd)
static

Definition at line 110 of file fstream_unistd.cpp.

110 {
111 streamoff ret = 0;
112
113 struct STAT buf;
114 if (FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode))
115 ret = buf.st_size > 0 ? buf.st_size : 0;
116
117 return ret;
118}
#define S_ISREG(mode)
Definition: various.h:17
off_t streamoff
Definition: char_traits.h:74
#define STAT
#define FSTAT
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static int fd
Definition: io.c:51
int ret

◆ __is_regular_file()

static _STLP_MOVE_TO_PRIV_NAMESPACE bool __is_regular_file ( _STLP_fd  fd)
static

Definition at line 104 of file fstream_unistd.cpp.

104 {
105 struct STAT buf;
106 return FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode);
107}

◆ flag_to_openmode()

static _STLP_BEGIN_NAMESPACE ios_base::openmode flag_to_openmode ( int  mode)
static

Definition at line 78 of file fstream_unistd.cpp.

79{
80 ios_base::openmode ret = ios_base::__default_mode;
81
82 switch ( mode & O_ACCMODE ) {
83 case O_RDONLY:
84 ret = ios_base::in;
85 break;
86 case O_WRONLY:
87 ret = ios_base::out;
88 break;
89 case O_RDWR:
90 ret = ios_base::in | ios_base::out;
91 break;
92 }
93
94 if ( mode & O_APPEND )
95 ret |= ios_base::app;
96
97 return ret;
98}
#define O_WRONLY
Definition: acwin.h:111
#define O_RDONLY
Definition: acwin.h:108
int openmode
Definition: _ios_base.h:59
#define O_ACCMODE
GLenum mode
Definition: glext.h:6217
#define O_RDWR
Definition: fcntl.h:36
#define O_APPEND
Definition: fcntl.h:37

Variable Documentation

◆ INVALID_STLP_FD

const _STLP_fd INVALID_STLP_FD = -1

Definition at line 50 of file fstream_unistd.cpp.