Remove File::tryOpen
authorTom Jackson <tjackson@fb.com>
Wed, 6 Mar 2013 23:27:38 +0000 (15:27 -0800)
committerJordan DeLong <jdelong@fb.com>
Tue, 19 Mar 2013 00:08:18 +0000 (17:08 -0700)
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

folly/File.cpp
folly/File.h
folly/test/FileTest.cpp

index 4998ec1fa1113067d94f3566121b2ec32d1c8ce7..1262dd1c3aaedab8616e2d45d19a9c1267147c02 100644 (file)
@@ -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;
index edcad92025bcf996ffd4ed66dd77766c9f414520..e990c91bfc14efcd0274dc01c6c84edf63237315 100644 (file)
@@ -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.
    */
index 96ebb7e5636f0f6ca44c23d6f96315663c23196a..4f47f0fec2b2e6328e9d29941acdb657165b8258 100644 (file)
@@ -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"));
-}