blob: 87c372a183634aeca4dfd055cad43345ada72d0d [file] [log] [blame]
====== DiskFile ======
{{anchor:torch.DiskFile.dok}}
Parent classes: [[File|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|File]], and
some additional methods relative to //endian// encoding.
By default, a ''DiskFile'' is in [[File#torch.File.binary|ASCII]] mode. If changed to
the [[File#torch.File.binary|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|torch.DiskFile(fileName, mode)]].
==== torch.DiskFile(fileName, [mode], [quiet]) ====
{{anchor:torch.DiskFile}}
//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 [[File#torch.File.ascii|ASCII]] mode by default.
==== bigEndianEncoding() ====
{{anchor:torch.DiskFile.bigEndianEncoding}}
In [[file#torch.File.binary|binary]] mode, force encoding in //big endian//.
(//big end first//: decreasing numeric significance with increasing memory
addresses)
==== [boolean] isBigEndianCPU() ====
{{anchor:torch.DiskFile.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() ====
{{anchor:torch.DiskFile.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() ====
{{anchor:torch.DiskFile.littleEndianEncoding}}
In [[file#torch.File.binary|binary]] mode, force encoding in //little endian//.
(//little end first//: increasing numeric significance with increasing memory
addresses)
==== nativeEndianEncoding() ====
{{anchor:torch.DiskFile.nativeEndianEncoding}}
In [[file#torch.File.binary|binary]] mode, force encoding in //native endian//.