Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
fml::ScopedTemporaryDirectory Class Reference

#include <file.h>

Public Member Functions

 ScopedTemporaryDirectory ()
 
 ~ScopedTemporaryDirectory ()
 
const std::string & path () const
 
const UniqueFDfd ()
 

Detailed Description

Definition at line 140 of file file.h.

Constructor & Destructor Documentation

◆ ScopedTemporaryDirectory()

fml::ScopedTemporaryDirectory::ScopedTemporaryDirectory ( )

Definition at line 47 of file file.cc.

48 : path_(CreateTemporaryDirectory()) {
49 if (path_ != "") {
50 dir_fd_ = OpenDirectory(path_.c_str(), false, FilePermission::kRead);
51 }
52}
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition file_posix.cc:97
std::string CreateTemporaryDirectory()
Definition file_posix.cc:25

◆ ~ScopedTemporaryDirectory()

fml::ScopedTemporaryDirectory::~ScopedTemporaryDirectory ( )

Definition at line 54 of file file.cc.

54 {
55 // POSIX requires the directory to be empty before UnlinkDirectory.
56 if (path_ != "") {
57 if (!RemoveFilesInDirectory(dir_fd_)) {
58 FML_LOG(ERROR) << "Could not clean directory: " << path_;
59 }
60 }
61
62 // Windows has to close UniqueFD first before UnlinkDirectory
63 dir_fd_.reset();
64 if (path_ != "") {
65 if (!UnlinkDirectory(path_.c_str())) {
66 FML_LOG(ERROR) << "Could not remove directory: " << path_;
67 }
68 }
69}
void reset(const T &value=Traits::InvalidValue())
#define FML_LOG(severity)
Definition logging.h:82
bool RemoveFilesInDirectory(const fml::UniqueFD &directory)
Definition file.cc:102
bool UnlinkDirectory(const char *path)
#define ERROR(message)

Member Function Documentation

◆ fd()

const UniqueFD & fml::ScopedTemporaryDirectory::fd ( )
inline

Definition at line 147 of file file.h.

147{ return dir_fd_; }

◆ path()

const std::string & fml::ScopedTemporaryDirectory::path ( ) const
inline

Definition at line 146 of file file.h.

146{ return path_; }

The documentation for this class was generated from the following files: