Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 2.41 KB

diskfile.md

File metadata and controls

65 lines (44 loc) · 2.41 KB

DiskFile

Parent classes: File

A DiskFile is a particular File which is able to perform basic read/write operations on a file stored on disk. It implements all methods described in File, and some additional methods relative to endian encoding.

By default, a DiskFile is in ASCII mode. If changed to the binary mode, the default endian encoding is the native computer one.

The file might be open in read, write, or read-write mode, depending on the parameter mode (which can take the value "r", "w" or "rw" respectively) given to the torch.DiskFile(fileName, mode).

torch.DiskFile(fileName, [mode], [quiet])

Constructor which opens fileName on disk, using the given mode. Valid mode are "r" (read), "w" (write) or "rw" (read-write). Default is read mode.

If read-write mode, the file will be created if it does not exists. If it exists, it will be positionned at the beginning of the file after opening.

If (and only if) quiet is true, no error will be raised in case of problem opening the file: instead nil will be returned.

The file is opened in ASCII mode by default.

bigEndianEncoding()

In binary mode, force encoding in big endian. (big end first: decreasing numeric significance with increasing memory addresses)

[boolean] isBigEndianCPU()

Returns true if, and only if, the computer CPU operates in big endian. Big end first: decreasing numeric significance with increasing memory addresses.

[boolean] isLittleEndianCPU()

Returns true if, and only if, the computer CPU operates in little endian. Little end first: increasing numeric significance with increasing memory addresses.

littleEndianEncoding()

In binary mode, force encoding in little endian. (little end first: increasing numeric significance with increasing memory addresses)

nativeEndianEncoding()

In binary mode, force encoding in native endian.