-
Notifications
You must be signed in to change notification settings - Fork 11
Chase Willden edited this page May 11, 2016
·
4 revisions
### fs
The base object for all file operations.
#### readFile [Function] \(string path)
Reading the contents of a file
##### Example
```go
fs.readFile("readme.md");
```
#### writeFile [Function] \(string path, string contents)
Writing the contents to a file. If the file exists, the contents will erase what was previously there.
##### Example
```go
fs.writeFile("readme.md", "This is a test");
```
#### fileExists [Function] \(string path)
Checks to see if a file exists.
##### Example
```go
bool exists = fs.fileExists("readme.md");
```
#### removeFile [Function] \(string path)
Removes a file, returns true if it actually is removed.
##### Example
```go
bool removed = fs.removeFile("text.txt");
```
#### readDir [Function] \(string path, bool recursive)
Reads a director and returns an array of strings. If recursive, it will return a larger array of strings.
##### Example
```go
import "fs", "console", "array"
var dir = fs.readDir("./", true);
for (int i = 0; i < arylen(dir); i++){ println(dir[i]); }
<a name="isDir" />
#### isDir [Function] \(string path)
Returns true if the path is a directory.
##### Example
```go
import "console", "fs", "array"
var dir = fs.readDir("./", true);
for (int i = 0; i < arylen(dir); i++){
if (fs.isDir(dir[i])){
println(dir[i]);
}
}