Class AbstractEmuUnixFile<T>
- Type Parameters:
T- the type of values stored in the file
- All Implemented Interfaces:
EmuUnixFile<T>
- Direct Known Subclasses:
BytesEmuUnixFileSystem.BytesEmuUnixFile
Contrast this with DefaultEmuUnixFileHandle, which is a particular process's handle when
opening the file, not the file itself.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EmuFileContents<T> protected final Stringprotected final EmuUnixFileStat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract EmuFileContents<T> A factory method for the file's default contentsprotected EmuUnixFileStatA factory method for the file'sstatstructure.Get the original pathname of this filegetStat()Get the file'sstatstructure, as defined by the simulator.read(PcodeArithmetic<T> arithmetic, T offset, T buf) Read contents from the file starting at the given offset into the given buffervoidtruncate()Erase the contents of the filewrite(PcodeArithmetic<T> arithmetic, T offset, T buf) Write contents into the file starting at the given offset from the given bufferMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.pcode.emu.unix.EmuUnixFile
checkReadable, checkWritable, isReadable, isWritable
-
Field Details
-
pathname
-
stat
-
contents
-
-
Constructor Details
-
AbstractEmuUnixFile
Construct a new fileTODO: Technically, a file can be hardlinked to several pathnames, but for simplicity, or for diagnostics, we let the file know its own original name.
- Parameters:
pathname- the pathname of the filemode- the mode of the file- See Also:
-
-
Method Details
-
createStat
A factory method for the file'sstatstructure.- Returns:
- the stat structure.
-
createDefaultContents
A factory method for the file's default contents- Returns:
- the contents
-
getPathname
Description copied from interface:EmuUnixFileGet the original pathname of this fileDepending on the fidelity of the file system simulator, and the actions taken by the target program, the file may no longer actually exist at this path, but it ought be have been the pathname at some point in the file life.
- Specified by:
getPathnamein interfaceEmuUnixFile<T>- Returns:
- the pathname
-
getStat
Description copied from interface:EmuUnixFileGet the file'sstatstructure, as defined by the simulator.- Specified by:
getStatin interfaceEmuUnixFile<T>- Returns:
- the stat
-
read
Description copied from interface:EmuUnixFileRead contents from the file starting at the given offset into the given bufferThis roughly follows the semantics of the UNIX
read(). While the offset and return value may depend on the arithmetic, the actual contents read from the file should not.- Specified by:
readin interfaceEmuUnixFile<T>- Parameters:
arithmetic- the arithmeticoffset- the offsetbuf- the buffer- Returns:
- the number of bytes read
-
write
Description copied from interface:EmuUnixFileWrite contents into the file starting at the given offset from the given bufferThis roughly follows the semantics of the UNIX
write(). While the offset and return value may depend on the arithmetic, the actual contents written to the file should not.- Specified by:
writein interfaceEmuUnixFile<T>- Parameters:
arithmetic- the arithmeticoffset- the offsetbuf- the buffer- Returns:
- the number of bytes written
-
truncate
public void truncate()Description copied from interface:EmuUnixFileErase the contents of the file- Specified by:
truncatein interfaceEmuUnixFile<T>
-