Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
namespace_win.cc
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "platform/globals.h"
6#if defined(DART_HOST_OS_WINDOWS)
7
8#include "bin/namespace.h"
9
10#include <errno.h>
11#include <sys/stat.h>
12
13#include "bin/file.h"
14#include "bin/file_win.h"
15#include "bin/utils.h"
16#include "bin/utils_win.h"
17
18namespace dart {
19namespace bin {
20
21Namespace* Namespace::Create(intptr_t namespc) {
22 return new Namespace(nullptr);
23}
24
25Namespace* Namespace::Create(const char* path) {
27 return nullptr;
28}
29
30Namespace::~Namespace() {
31 ASSERT(namespc_ == nullptr);
32}
33
34intptr_t Namespace::Default() {
35 return kNone;
36}
37
38const char* Namespace::GetCurrent(Namespace* namespc) {
39 int length = GetCurrentDirectoryW(0, nullptr);
40 if (length == 0) {
41 return nullptr;
42 }
43 wchar_t* current;
44 current = reinterpret_cast<wchar_t*>(
45 Dart_ScopeAllocate((length + 1) * sizeof(*current)));
46 GetCurrentDirectoryW(length + 1, current);
47 return StringUtilsWin::WideToUtf8(current);
48}
49
50bool Namespace::SetCurrent(Namespace* namespc, const char* path) {
51 // SetCurrentDirectory does not actually support paths larger than MAX_PATH,
52 // this limitation is due to the size of the internal buffer used for storing
53 // current directory. In Windows 10, version 1607, changes have been made
54 // to the OS to lift MAX_PATH limitations from file and directory management
55 // APIs, but both application and OS need to opt-in into new behavior.
56 // See https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later
57 const auto system_path = Utf8ToWideChar(path);
58 bool result = SetCurrentDirectoryW(system_path.get()) != 0;
59 return result;
60}
61
62void Namespace::ResolvePath(Namespace* namespc,
63 const char* path,
64 intptr_t* dirfd,
65 const char** resolved_path) {
67}
68
69NamespaceScope::NamespaceScope(Namespace* namespc, const char* path) {
71}
72
75}
76
77} // namespace bin
78} // namespace dart
79
80#endif // defined(DART_HOST_OS_WINDOWS)
NamespaceScope(Namespace *namespc, const char *path)
static Namespace * Create(intptr_t namespc)
static const char * GetCurrent(Namespace *namespc)
static intptr_t Default()
static bool SetCurrent(Namespace *namespc, const char *path)
static char * WideToUtf8(wchar_t *wide, intptr_t len=-1, intptr_t *result_len=nullptr)
#define UNIMPLEMENTED
#define ASSERT(E)
GAsyncResult * result
size_t length
std::unique_ptr< wchar_t[]> Utf8ToWideChar(const char *path)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)