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

Side by Side Diff: runtime/bin/file_system_watcher_win.cc

Issue 48513003: If a move has matching target/destination, signal the event as create or delete. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix list size Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_system_watcher_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file_system_watcher.h" 8 #include "bin/file_system_watcher.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 intptr_t max_count = available / kEventSize + 1; 76 intptr_t max_count = available / kEventSize + 1;
77 Dart_Handle events = Dart_NewList(max_count); 77 Dart_Handle events = Dart_NewList(max_count);
78 uint8_t* buffer = new uint8_t[available]; 78 uint8_t* buffer = new uint8_t[available];
79 intptr_t bytes = dir->Read(buffer, available); 79 intptr_t bytes = dir->Read(buffer, available);
80 intptr_t offset = 0; 80 intptr_t offset = 0;
81 intptr_t i = 0; 81 intptr_t i = 0;
82 while (offset < bytes) { 82 while (offset < bytes) {
83 FILE_NOTIFY_INFORMATION* e = 83 FILE_NOTIFY_INFORMATION* e =
84 reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer + offset); 84 reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer + offset);
85 85
86 Dart_Handle event = Dart_NewList(3); 86 Dart_Handle event = Dart_NewList(4);
87 int mask = 0; 87 int mask = 0;
88 if (e->Action == FILE_ACTION_ADDED) mask |= kCreate; 88 if (e->Action == FILE_ACTION_ADDED) mask |= kCreate;
89 if (e->Action == FILE_ACTION_REMOVED) mask |= kDelete; 89 if (e->Action == FILE_ACTION_REMOVED) mask |= kDelete;
90 if (e->Action == FILE_ACTION_MODIFIED) mask |= kModifyContent; 90 if (e->Action == FILE_ACTION_MODIFIED) mask |= kModifyContent;
91 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) mask |= kMove; 91 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) mask |= kMove;
92 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) mask |= kMove; 92 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) mask |= kMove;
93 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); 93 Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
94 // Move events come in pairs. Just 'enable' by default. 94 // Move events come in pairs. Just 'enable' by default.
95 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); 95 Dart_ListSetAt(event, 1, Dart_NewInteger(1));
96 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16( 96 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16(
97 reinterpret_cast<uint16_t*>(e->FileName), e->FileNameLength / 2)); 97 reinterpret_cast<uint16_t*>(e->FileName), e->FileNameLength / 2));
98 98 Dart_ListSetAt(event, 3, Dart_NewBoolean(true));
99 Dart_ListSetAt(events, i, event); 99 Dart_ListSetAt(events, i, event);
100 i++; 100 i++;
101 if (e->NextEntryOffset == 0) break; 101 if (e->NextEntryOffset == 0) break;
102 offset += e->NextEntryOffset; 102 offset += e->NextEntryOffset;
103 } 103 }
104 delete[] buffer; 104 delete[] buffer;
105 return events; 105 return events;
106 } 106 }
107 107
108 } // namespace bin 108 } // namespace bin
109 } // namespace dart 109 } // namespace dart
110 110
111 #endif // defined(TARGET_OS_WINDOWS) 111 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698