File¶
Operations on a file.
Constructors¶
create¶
Attempt to open for read/write, creating if it doesn't exist, preserving the contents if it does exist. Set errno according to result.
Parameters¶
- from: FilePath val
Returns¶
- File ref^
open¶
Open for read only. Set _errno according to result.
Parameters¶
- from: FilePath val
Returns¶
- File ref^
Public fields¶
let path: FilePath val¶
This is the filesystem path locating this file on the file system and an object capability granting access to operate on this file.
let writeable: Bool val¶
true
if the underlying file descriptor has been opened as writeable.
Public Functions¶
errno¶
Returns the last error code set for this File
fun box errno()
: (FileOK val | FileError val | FileEOF val |
FileBadFileNumber val | FileExists val | FilePermissionDenied val)
Returns¶
- (FileOK val | FileError val | FileEOF val | FileBadFileNumber val | FileExists val | FilePermissionDenied val)
clear_errno¶
Clears the last error code set for this File. Clears the error indicator for the stream.
Returns¶
- None val
valid¶
Returns true if the file is currently open.
Returns¶
- Bool val
read¶
Returns up to len bytes.
Parameters¶
- len: USize val
Returns¶
read_string¶
Returns up to len bytes. The resulting string may have internal null characters.
Parameters¶
- len: USize val
Returns¶
- String iso^
print¶
Same as write, buts adds a newline.
Parameters¶
Returns¶
- Bool val
printv¶
Print an iterable collection of ByteSeqs.
Parameters¶
- data: ByteSeqIter box
Returns¶
- Bool val
write¶
Returns false if the file wasn't opened with write permission. Returns false and closes the file if not all the bytes were written.
Parameters¶
Returns¶
- Bool val
writev¶
Write an iterable collection of ByteSeqs.
Parameters¶
- data: ByteSeqIter box
Returns¶
- Bool val
queue¶
Queue data to be written NOTE: Queue'd data will always be written before normal print/write requested data
Parameters¶
Returns¶
- None val
queuev¶
Queue an iterable collection of ByteSeqs to be written NOTE: Queue'd data will always be written before normal print/write requested data
Parameters¶
- data: ByteSeqIter box
Returns¶
- None val
flush¶
Flush any queued data
Returns¶
- Bool val
position¶
Return the current cursor position in the file.
Returns¶
- USize val
size¶
Return the total length of the file.
Returns¶
- USize val
seek_start¶
Set the cursor position relative to the start of the file.
Parameters¶
- offset: USize val
Returns¶
- None val
seek_end¶
Set the cursor position relative to the end of the file.
Parameters¶
- offset: USize val
Returns¶
- None val
seek¶
Move the cursor position.
Parameters¶
- offset: ISize val
Returns¶
- None val
sync¶
Sync the file contents to physical storage.
Returns¶
- None val
datasync¶
Sync the file contents to physical storage.
Returns¶
- None val
set_length¶
Change the file size. If it is made larger, the new contents are undefined.
Parameters¶
- len: USize val
Returns¶
- Bool val
info¶
Return a FileInfo for this directory. Raise an error if the fd is invalid or if we don't have FileStat permission.
Returns¶
- FileInfo val ?
chmod¶
Set the FileMode for this directory.
Parameters¶
- mode: FileMode box
Returns¶
- Bool val
chown¶
Set the owner and group for this directory. Does nothing on Windows.
Parameters¶
Returns¶
- Bool val
touch¶
Set the last access and modification times of the directory to now.
Returns¶
- Bool val
set_time¶
Set the last access and modification times of the directory to the given values.
Parameters¶
Returns¶
- Bool val
lines¶
Returns an iterator for reading lines from the file.
Returns¶
- FileLines ref
dispose¶
Close the file. Future operations will do nothing.
Returns¶
- None val