Skip to content

Commit

Permalink
0.0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
mezoni committed Jul 15, 2014
1 parent c39051f commit ae5c5f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
37 changes: 13 additions & 24 deletions lib/src/file_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class FileUtils {
case "directory":
return new Directory(file).existsSync();
case "exists":
return FileStat.statSync(file) != FileSystemEntityType.NOT_FOUND;
return FileStat.statSync(file).type != FileSystemEntityType.NOT_FOUND;
case "file":
return new File(file).existsSync();
case "link":
Expand Down Expand Up @@ -709,43 +709,32 @@ class FileUtils {
}

/**
* Returns true if [name] is newer than all [other]; otherwise false.
*
* Non-existent files are older than any file.
* Returns true if [file] is newer than all [depends]; otherwise false.
*/
static bool uptodate(String name, [List<String> other]) {
if (name == null || name.isEmpty) {
static bool uptodate(String file, [List<String> depends]) {
if (file == null || file.isEmpty) {
return false;
}

name = FilePath.expand(name);
var stat = FileStat.statSync(name);
file = FilePath.expand(file);
var stat = FileStat.statSync(file);
if (stat.type == FileSystemEntityType.NOT_FOUND) {
return false;
}

if (other == null) {
if (depends == null) {
return true;
}

var date = stat.modified;
for (var name in other) {
if (name.isEmpty) {
continue;
}

var list = glob(name);
if (list.isEmpty) {
continue;
for (var name in depends) {
var stat = FileStat.statSync(name);
if (stat.type == FileSystemEntityType.NOT_FOUND) {
return false;
}

for (var name in list) {
var stat = FileStat.statSync(name);
if (stat.type != FileSystemEntityType.NOT_FOUND) {
if (date.compareTo(stat.modified) < 0) {
return false;
}
}
if (date.compareTo(stat.modified) < 0) {
return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: file_utils
version: 0.0.22
version: 0.0.23
author: Andrew Mezoni <[email protected]>
description: File utils is a collection of the helper classes for file system.
homepage: https://github.com/mezoni/file_utils
Expand Down
4 changes: 2 additions & 2 deletions test/test_file_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ void testSymlinkOnWindows() {
}

void testTestfile() {
var subject = "FileUtils.test()";
var subject = "FileUtils.testfile()";

// Clean
clean();
Expand Down Expand Up @@ -757,7 +757,7 @@ void testUptodate() {

// Existent and non-existent
result = FileUtils.uptodate("file1", ["file2"]);
expect(result, true, reason: "$subject, existent and non-existent");
expect(result, false, reason: "$subject, existent and non-existent");

// Older and newer
wait(1000);
Expand Down

0 comments on commit ae5c5f4

Please sign in to comment.