From a7a625dc3ff5b70967de8238ec01f0d2cede36dd Mon Sep 17 00:00:00 2001 From: ksherlock Date: Fri, 21 May 2010 18:51:00 +0000 Subject: [PATCH] no throw file open git-svn-id: https://profuse.googlecode.com/svn/branches/v2@250 aa027e90-d47c-11dd-86d7-074df07e0730 --- File/File.cpp | 10 ++++++++++ File/File.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/File/File.cpp b/File/File.cpp index d1d3e49..11e8604 100644 --- a/File/File.cpp +++ b/File/File.cpp @@ -26,6 +26,16 @@ File::File(File& f) f._fd = -1; } +File::File(const char *name, int flags, const std::nothrow_t&) +{ + _fd = ::open(name, flags); +} + +File::File(const char *name, bool readOnly, const std::nothrow_t&) +{ + _fd = ::open(name, readOnly ? O_RDONLY : O_RDWR); +} + File::File(const char *name, int flags) { #undef __METHOD__ diff --git a/File/File.h b/File/File.h index 5ada61d..2d83591 100644 --- a/File/File.h +++ b/File/File.h @@ -1,6 +1,8 @@ #ifndef __FILE_H__ #define __FILE_H__ +#include + #include #include #include @@ -12,8 +14,13 @@ class File { File(); File(File &); File(int fd); + File(const char *name, int flags); File(const char *name, bool readOnly); + + File(const char *name, int flags, const std::nothrow_t &); + File(const char *name, bool readOnly, const std::nothrow_t &); + ~File(); bool isValid() const