Emojicode Documentation 0.8
Guides Language Reference Package Index

Class ๐Ÿ“„

The ๐Ÿ“„ class allows you to read and write to files.

It provides several class methods which are shortcuts to reading and writing. They operate always on the whole file and reading can be very inefficient using these shortcuts when working with big files, because they will read the whole file into memory.

You must close files openend with ๐Ÿ“ and ๐Ÿ“œ appropriately with ๐Ÿ™… when they are no longer needed.

Initializers

๐Ÿ“

๐Ÿ†• ๐Ÿ“ ๐Ÿšจ๐ŸŒง message ๐Ÿ”ก 

Opens the file at the given path for writing. The file pointer is set to the beginning of the file and the file is truncated to zero length or created.

You cannot read from a file opened with this initializer.

๐Ÿ“œ

๐Ÿ†• ๐Ÿ“œ ๐Ÿšจ๐ŸŒง message ๐Ÿ”ก 

Opens the file at the given path for reading. The file pointer is set to the beginning of the file.

You cannot write to a file opened with this initializer.

Methods

โœโ—๏ธ

โ—๏ธ โœ data ๐Ÿ“‡ โžก๏ธ ๐Ÿฌ๐ŸŒง

Write the data at the current file pointer position.

๐Ÿ““โ—๏ธ

โ—๏ธ ๐Ÿ““ bytesToRead ๐Ÿ”ข โžก๏ธ ๐Ÿšจ๐ŸŒง๐Ÿ“‡

Reads as many bytes as specified from the file pointer position.

Keep in mind that a byte is not equal to one character!

๐Ÿ”šโ—๏ธ

โ—๏ธ ๐Ÿ”š 

Seeks the file pointer to the end of the file.

๐Ÿ”›โ—๏ธ

โ—๏ธ ๐Ÿ”› position ๐Ÿ”ข 

Seeks the file pointer to the given position.

๐Ÿ’งโ—๏ธ

โ—๏ธ ๐Ÿ’ง 

Causes any buffered unwritten data to be written to the file.

๐Ÿšชโ—๏ธ

โ—๏ธ ๐Ÿšช 

Closes the file. Reading or writing thereafter is undefined behavior.

Type Methods

๐Ÿ“ป

๐Ÿ‡โ—๏ธ ๐Ÿ“ป path ๐Ÿ”ก data ๐Ÿ“‡ โžก๏ธ ๐Ÿฌ๐ŸŒง

This class method tries to write the given ๐Ÿ“‡ to the given path. If the file already exists, it will be overwritten.

๐Ÿ“‡

๐Ÿ‡โ—๏ธ ๐Ÿ“‡ path ๐Ÿ”ก โžก๏ธ ๐Ÿšจ๐ŸŒง๐Ÿ“‡

This class method tries to read the file at given path path and returns a ๐Ÿ“‡ object representing its content on success. On failure an error is returned.