Skip to content

Commit

Permalink
Create stat_file.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrawl authored Oct 29, 2023
1 parent 69b0488 commit ea61f79
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions docs/API/runtime/stat_file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# stat_file

This function takes in one parameter. The parameter is the file path and assumes the the game directory is the root. The method returns nil if the file doesn't exist otherwise it returns a Hash with the following information:

```ruby
# {
# path: String,
# file_size: Int,
# mod_time: Int,
# create_time: Int,
# access_time: Int,
# readonly: Boolean,
# file_type: Symbol (:regular, :directory, :symlink, :other),
# }

def tick args
if args.inputs.mouse.click
args.gtk.write_file "last-mouse-click.txt", "Mouse was clicked at #{args.state.tick_count}."
end

file_info = args.gtk.stat_file "last-mouse-click.txt"

if file_info
args.outputs.labels << {
x: 30,
y: 30.from_top,
text: file_info.to_s,
size_enum: -3
}
else
args.outputs.labels << {
x: 30,
y: 30.from_top,
text: "file does not exist, click to create file",
size_enum: -3
}
end
end
```

0 comments on commit ea61f79

Please sign in to comment.