From: Tom Jackson Date: Wed, 6 Mar 2013 23:27:38 +0000 (-0800) Subject: Remove File::tryOpen X-Git-Tag: v0.22.0~1044 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a6fac16f6b71d04aaa8be6f5c0f2a1e7e70d6915;p=folly.git Remove File::tryOpen Summary: In hopes of keeping 'busywork' helpers out of folly, I've moved this closer to the code that needed to do this. Test Plan: Unit tests Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D729194 Blame Revision: D726916 --- diff --git a/folly/File.cpp b/folly/File.cpp index 4998ec1f..1262dd1c 100644 --- a/folly/File.cpp +++ b/folly/File.cpp @@ -79,16 +79,6 @@ File::~File() { return File(fd, true); } -/* static */ File File::tryOpen(const char* name, - int flags, - mode_t mode) { - try { - return File(name, flags, mode); - } catch (const std::system_error&) { - return File(); - } -} - void File::release() { fd_ = -1; ownsFd_ = false; diff --git a/folly/File.h b/folly/File.h index edcad920..e990c91b 100644 --- a/folly/File.h +++ b/folly/File.h @@ -54,14 +54,6 @@ class File { */ static File temporary(); - /** - * Attempts to open the file at the given path. Returns an 'closed` File - * instance on failure, which will evaluate to false. - */ - static File tryOpen(const char* name, - int flags = O_RDONLY, - mode_t mode = 0644); - /** * Return the file descriptor, or -1 if the file was closed. */ diff --git a/folly/test/FileTest.cpp b/folly/test/FileTest.cpp index 96ebb7e5..4f47f0fe 100644 --- a/folly/test/FileTest.cpp +++ b/folly/test/FileTest.cpp @@ -122,8 +122,3 @@ TEST(File, Truthy) { EXPECT_TRUE(false); } } - -TEST(File, TryOpen) { - EXPECT_FALSE(!!File::tryOpen("does_not_exist.txt")); - EXPECT_TRUE(!!File::tryOpen("/etc/fstab")); -}