Skip to content

Commit 03337e9

Browse files
committed
Wrap Directory.watch on Mac OS for the watcher package.
[email protected] BUG=14428 Review URL: https://codereview.chromium.org//66163002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30168 260f80e4-7a28-3924-810f-c04153c831b5
1 parent a00c36e commit 03337e9

File tree

13 files changed

+983
-2
lines changed

13 files changed

+983
-2
lines changed

pkg/pkg.status

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,11 @@ unittest/test/mock_test: StaticWarning, OK # testing unimplemented members
330330
[ $runtime == vm && ($system == windows || $system == macos) ]
331331
watcher/test/*/linux_test: Skip
332332

333+
[ $runtime == vm && ($system == windows || $system == linux) ]
334+
watcher/test/*/mac_os_test: Skip
335+
333336
[ $runtime == vm && $system == linux ]
334337
watcher/test/*/linux_test: Pass, Slow # Issue 14606
338+
339+
[ $runtime == vm && $system == macos ]
340+
watcher/test/no_subscribers/mac_os_test: Fail # Issue 14793 (see test file for details)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library watcher.constructable_file_system_event;
6+
7+
import 'dart:io';
8+
9+
abstract class _ConstructableFileSystemEvent implements FileSystemEvent {
10+
final bool isDirectory;
11+
final String path;
12+
final int type;
13+
14+
_ConstructableFileSystemEvent(this.path, this.isDirectory);
15+
}
16+
17+
class ConstructableFileSystemCreateEvent extends _ConstructableFileSystemEvent
18+
implements FileSystemCreateEvent {
19+
final type = FileSystemEvent.CREATE;
20+
21+
ConstructableFileSystemCreateEvent(String path, bool isDirectory)
22+
: super(path, isDirectory);
23+
24+
String toString() => "FileSystemCreateEvent('$path')";
25+
}
26+
27+
class ConstructableFileSystemDeleteEvent extends _ConstructableFileSystemEvent
28+
implements FileSystemDeleteEvent {
29+
final type = FileSystemEvent.DELETE;
30+
31+
ConstructableFileSystemDeleteEvent(String path, bool isDirectory)
32+
: super(path, isDirectory);
33+
34+
String toString() => "FileSystemDeleteEvent('$path')";
35+
}
36+
37+
class ConstructableFileSystemModifyEvent extends _ConstructableFileSystemEvent
38+
implements FileSystemModifyEvent {
39+
final bool contentChanged;
40+
final type = FileSystemEvent.MODIFY;
41+
42+
ConstructableFileSystemModifyEvent(String path, bool isDirectory,
43+
this.contentChanged)
44+
: super(path, isDirectory);
45+
46+
String toString() =>
47+
"FileSystemModifyEvent('$path', contentChanged=$contentChanged)";
48+
}
49+
50+
class ConstructableFileSystemMoveEvent extends _ConstructableFileSystemEvent
51+
implements FileSystemMoveEvent {
52+
final String destination;
53+
final type = FileSystemEvent.MOVE;
54+
55+
ConstructableFileSystemMoveEvent(String path, bool isDirectory,
56+
this.destination)
57+
: super(path, isDirectory);
58+
59+
String toString() => "FileSystemMoveEvent('$path', '$destination')";
60+
}

pkg/watcher/lib/src/directory_watcher.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'dart:io';
99

1010
import 'watch_event.dart';
1111
import 'directory_watcher/linux.dart';
12+
import 'directory_watcher/mac_os.dart';
1213
import 'directory_watcher/polling.dart';
1314

1415
/// Watches the contents of a directory and emits [WatchEvent]s when something
@@ -54,6 +55,7 @@ abstract class DirectoryWatcher {
5455
/// watchers.
5556
factory DirectoryWatcher(String directory, {Duration pollingDelay}) {
5657
if (Platform.isLinux) return new LinuxDirectoryWatcher(directory);
58+
if (Platform.isMacOS) return new MacOSDirectoryWatcher(directory);
5759
return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay);
5860
}
5961
}

pkg/watcher/lib/src/directory_watcher/linux.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import '../utils.dart';
1212
import '../watch_event.dart';
1313
import 'resubscribable.dart';
1414

15-
import 'package:stack_trace/stack_trace.dart';
16-
1715
/// Uses the inotify subsystem to watch for filesystem events.
1816
///
1917
/// Inotify doesn't suport recursively watching subdirectories, nor does

0 commit comments

Comments
 (0)