mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
7fe505ca3c
The fd passed to fdopendir will be unusable afterward. Using a duplicate preserves the validity of the original directory fd passed to VisitFiles. Fixes https://github.com/flutter/flutter/issues/43844
40 lines
635 B
C++
40 lines
635 B
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/fml/unique_fd.h"
|
|
|
|
#include "flutter/fml/eintr_wrapper.h"
|
|
|
|
namespace fml {
|
|
namespace internal {
|
|
|
|
#if OS_WIN
|
|
|
|
namespace os_win {
|
|
|
|
void UniqueFDTraits::Free(HANDLE fd) {
|
|
CloseHandle(fd);
|
|
}
|
|
|
|
} // namespace os_win
|
|
|
|
#else // OS_WIN
|
|
|
|
namespace os_unix {
|
|
|
|
void UniqueFDTraits::Free(int fd) {
|
|
close(fd);
|
|
}
|
|
|
|
void UniqueDirTraits::Free(DIR* dir) {
|
|
closedir(dir);
|
|
}
|
|
|
|
} // namespace os_unix
|
|
|
|
#endif // OS_WIN
|
|
|
|
} // namespace internal
|
|
} // namespace fml
|