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

Side by Side Diff: pkg/watcher/lib/src/stat.dart

Issue 18612013: File watching package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.stat;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 typedef DateTime MockTimeCallback(String path);
nweiz 2013/07/11 00:25:01 Document this.
Bob Nystrom 2013/07/11 18:33:20 Done.
11
12 MockTimeCallback _mockTimeCallback;
13
14 /// Overrided the default behavior for accessing a file's modification time with
nweiz 2013/07/11 00:25:01 "Overrided" -> "Override"
Bob Nystrom 2013/07/11 18:33:20 "Overrides". Done.
15 /// [callback].
16 ///
17 /// The OS file modification time has pretty rough granularity (like a few
18 /// seconds) which can make for slow tests that rely on modtime. This lets you
19 /// replace it with something you control.
20 void mockGetModificationTime(MockTimeCallback callback) {
21 _mockTimeCallback = callback;
22 }
23
24 /// Gets the modification time for the file at [path].
25 Future<DateTime> getModificationTime(String path) {
26 if (_mockTimeCallback != null) {
27 return new Future.value(_mockTimeCallback(path));
28 }
29
30 return FileStat.stat(path).then((stat) => stat.modified);
31 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698