forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify file sharing flags in FML filesystem APIs on Windows (flutter…
…#38164) Use shared mode when requesting read access and exclusive mode for write access
- Loading branch information
1 parent
c3ddd56
commit a83b3a6
Showing
4 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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/file.h" | ||
|
||
#include <Fileapi.h> | ||
|
||
#include "flutter/fml/platform/win/wstring_conversion.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace fml { | ||
namespace testing { | ||
|
||
TEST(FileWin, OpenDirectoryShare) { | ||
fml::ScopedTemporaryDirectory temp_dir; | ||
auto temp_path = Utf8ToWideString({temp_dir.path()}); | ||
fml::UniqueFD handle( | ||
CreateFile(temp_path.c_str(), GENERIC_WRITE, | ||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, | ||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, nullptr)); | ||
ASSERT_TRUE(handle.is_valid()); | ||
|
||
// Check that fml::OpenDirectory(FilePermission::kRead) works with a | ||
// directory that has also been opened for writing. | ||
auto dir = fml::OpenDirectory(temp_dir.path().c_str(), false, | ||
fml::FilePermission::kRead); | ||
ASSERT_TRUE(dir.is_valid()); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace fml |