Skip to content

Commit

Permalink
add FilePath.length
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Apr 10, 2015
1 parent 5edd29d commit 329aa98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/grinder_files.dart
Expand Up @@ -229,6 +229,9 @@ class FilePath {
return link;
}

/// Return the file length; if this FilePath is not a File, return 0.
int get length => isFile ? asFile.lengthSync() : 0;

/// Join the given path elements to this path, and return a new [FilePath] object.
FilePath join([arg0, String arg1, String arg2, String arg3, String arg4,
String arg5, String arg6, String arg7, String arg8, String arg9]) {
Expand Down
7 changes: 7 additions & 0 deletions test/grinder_files_test.dart
Expand Up @@ -235,5 +235,12 @@ main() {
file.delete();
expect(file.exists, false);
});

test('length', () {
expect(temp.length, 0);
FilePath file = temp.join('temp.txt');
file.asFile.writeAsStringSync('foo\n', flush: true);
expect(file.length, 4);
});
});
}

0 comments on commit 329aa98

Please sign in to comment.