-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native_assets_builder] Automatically track all Dart sources as depen…
…dencies (#1322)
- Loading branch information
Showing
63 changed files
with
460 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
extension FileSystemEntityExtension on FileSystemEntity { | ||
Future<DateTime> lastModified() async { | ||
final this_ = this; | ||
if (this_ is Link || await FileSystemEntity.isLink(this_.path)) { | ||
// Don't follow links. | ||
return DateTime.fromMicrosecondsSinceEpoch(0); | ||
} | ||
if (this_ is File) { | ||
if (!await this_.exists()) { | ||
// If the file was deleted, regard it is modified recently. | ||
return DateTime.now(); | ||
} | ||
return await this_.lastModified(); | ||
} | ||
assert(this_ is Directory); | ||
this_ as Directory; | ||
return await this_.lastModified(); | ||
} | ||
} | ||
|
||
extension FileSystemEntityIterable on Iterable<FileSystemEntity> { | ||
Future<DateTime> lastModified() async { | ||
var last = DateTime.fromMillisecondsSinceEpoch(0); | ||
for (final entity in this) { | ||
final entityTimestamp = await entity.lastModified(); | ||
if (entityTimestamp.isAfter(last)) { | ||
// print([entity, entityTimestamp]); | ||
last = entityTimestamp; | ||
} | ||
} | ||
return last; | ||
} | ||
} | ||
|
||
extension DirectoryExtension on Directory { | ||
Future<DateTime> lastModified() async { | ||
var last = DateTime.fromMillisecondsSinceEpoch(0); | ||
await for (final entity in list()) { | ||
final entityTimestamp = await entity.lastModified(); | ||
if (entityTimestamp.isAfter(last)) { | ||
// print([this, entityTimestamp]); | ||
last = entityTimestamp; | ||
} | ||
} | ||
return last; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
extension UriExtension on Uri { | ||
FileSystemEntity get fileSystemEntity { | ||
if (path.endsWith(Platform.pathSeparator) || path.endsWith('/')) { | ||
return Directory.fromUri(this); | ||
} | ||
return File.fromUri(this); | ||
} | ||
} |
Oops, something went wrong.