// Copyright (c) 2011 Baidu.com, Inc. All Rights Reserved
//
// RAII file descriptor.
//
// Example:
//    fd_guard fd1(open(...));
//    if (fd1 < 0) {
//        printf("Fail to open\n");
//        return -1;
//    }
//    if (another-error-happened) {
//        printf("Fail to do sth\n");
//        return -1;   // *** closing fd1 automatically ***
//    }
//
// Author: Ge,Jun (gejun@baidu.com)
// Date: Mon. Nov 7 14:47:36 CST 2011

#ifndef BASE_FD_GUARD_H
#define BASE_FD_GUARD_H

#include "base/files/scoped_file.h"

namespace base {
namespace files {
class fd_guard : public ScopedFD {
public:
    operator int() const { return get(); }
};
}  // files
}  // base

#endif  // BASE_FD_GUARD_H