Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: runtime/bin/directory_win.cc

Issue 145623011: Allow paths up to 32767 characters on Windows (so '\\?\' can be used). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/file_windows_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index 27b0eea5a594e3eddee81c5859258a469a6015ea..eefdd58dd70c0a222ee8d4c21bfefc4d31e083f6 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -16,11 +16,13 @@
#undef DeleteFile
+#define MAX_LONG_PATH 32767
+
namespace dart {
namespace bin {
PathBuffer::PathBuffer() : length_(0) {
- data_ = calloc(MAX_PATH + 1, sizeof(wchar_t)); // NOLINT
+ data_ = calloc(MAX_LONG_PATH + 1, sizeof(wchar_t)); // NOLINT
}
char* PathBuffer::AsString() const {
@@ -41,13 +43,13 @@ bool PathBuffer::Add(const char* name) {
bool PathBuffer::AddW(const wchar_t* name) {
wchar_t* data = AsStringW();
int written = _snwprintf(data + length_,
- MAX_PATH - length_,
+ MAX_LONG_PATH - length_,
L"%s",
name);
- data[MAX_PATH] = L'\0';
- if (written <= MAX_PATH - length_ &&
+ data[MAX_LONG_PATH] = L'\0';
+ if (written <= MAX_LONG_PATH - length_ &&
written >= 0 &&
- static_cast<size_t>(written) == wcsnlen(name, MAX_PATH + 1)) {
+ static_cast<size_t>(written) == wcsnlen(name, MAX_LONG_PATH + 1)) {
length_ += written;
return true;
} else {
@@ -390,7 +392,8 @@ bool Directory::Create(const char* dir_name) {
char* Directory::SystemTemp() {
PathBuffer path;
- path.Reset(GetTempPathW(MAX_PATH, path.AsStringW()) - 1); // Remove \ at end.
+ // Remove \ at end.
+ path.Reset(GetTempPathW(MAX_LONG_PATH, path.AsStringW()) - 1);
return path.AsString();
}
@@ -407,7 +410,7 @@ char* Directory::CreateTemp(const char* prefix) {
free(const_cast<wchar_t*>(system_prefix));
// Length of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36.
- if (path.length() > MAX_PATH - 36) {
+ if (path.length() > MAX_LONG_PATH - 36) {
return NULL;
}
« no previous file with comments | « no previous file | tests/standalone/io/file_windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698