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

Side by Side Diff: which/lib/src/is_executable.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « which/lib/src/has_permission.dart ('k') | which/lib/src/util.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 library which.src.is_executable;
3
4 import 'dart:async';
5 import 'dart:io';
6
7 import 'package:when/when.dart';
8
9 import 'has_permission.dart';
10
11 Future<bool> isExecutable(String path, bool isWindows, Future<FileStat> getStat( path)) =>
12 _isExecutable(path, isWindows, getStat);
13
14 bool isExecutableSync(String path, bool isWindows, FileStat getStat(path)) =>
15 _isExecutable(path, isWindows, getStat);
16
17 _isExecutable(String path, bool isWindows, getStat(path)) =>
18 when(() => getStat(path), onSuccess: (stat) => isExecutableStat(stat, isWind ows));
19
20 /// Tests whether the file exists and is executable.
21 bool isExecutableStat(FileStat stat, bool isWindows) {
22 if (FileSystemEntityType.FILE != stat.type) return false;
23
24 // There is no concept of executable on windows.
25 if (isWindows) return true;
26
27 // TODO: This currently produces false positives (returns true when it
28 // shouldn't) when the uid/gid of current user and executable don't
29 // match. Fix if/when uid/gid support is added:
30 // http://dartbug.com/22037.
31 return FilePermissionRole.values.any((role) =>
32 hasPermission(stat.mode, FilePermission.EXECUTE, role: role));
33 }
OLDNEW
« no previous file with comments | « which/lib/src/has_permission.dart ('k') | which/lib/src/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698