Skip to content

Commit

Permalink
added read method
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanisham committed Dec 3, 2023
1 parent 9021911 commit acd1545
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lang/fs.fan
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ class Fs {
return null
}

/// Returns String or null
static read(path) {
if (path is String) {
var target = Path.from(path)
if (!target.exists()) {
return null
}

var file = File.open(path, "r")
var body = file.read()
file.close()

return body
}

return null
}

/**
* Removes file at given path. Will not delete directories
*/
Expand Down

0 comments on commit acd1545

Please sign in to comment.