| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "flutter/fml/unique_fd.h" |
| 6 | |
| 7 | #include "flutter/fml/eintr_wrapper.h" |
| 8 | |
| 9 | namespace fml { |
| 10 | namespace internal { |
| 11 | |
| 12 | #if FML_OS_WIN |
| 13 | |
| 14 | namespace os_win { |
| 15 | |
| 16 | std::mutex UniqueFDTraits::file_map_mutex; |
| 17 | std::map<HANDLE, DirCacheEntry> UniqueFDTraits::file_map; |
| 18 | |
| 19 | void UniqueFDTraits::Free_Handle(HANDLE fd) { |
| 20 | CloseHandle(fd); |
| 21 | } |
| 22 | |
| 23 | } // namespace os_win |
| 24 | |
| 25 | #else // FML_OS_WIN |
| 26 | |
| 27 | namespace os_unix { |
| 28 | |
| 29 | void UniqueFDTraits::Free(int fd) { |
| 30 | close(fd: fd); |
| 31 | } |
| 32 | |
| 33 | void UniqueDirTraits::Free(DIR* dir) { |
| 34 | closedir(dirp: dir); |
| 35 | } |
| 36 | |
| 37 | } // namespace os_unix |
| 38 | |
| 39 | #endif // FML_OS_WIN |
| 40 | |
| 41 | } // namespace internal |
| 42 | } // namespace fml |
| 43 | |