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
Modifier and TypeFieldDescriptionprotected EmuFileContents
<T> protected final String
protected final EmuUnixFileStat
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract EmuFileContents
<T> A factory method for the file's default contentsprotected EmuUnixFileStat
A factory method for the file'sstat
structure.Get the original pathname of this filegetStat()
Get the file'sstat
structure, 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 buffervoid
truncate()
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, wait
Methods 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'sstat
structure.- Returns:
- the stat structure.
-
createDefaultContents
A factory method for the file's default contents- Returns:
- the contents
-
getPathname
Description copied from interface:EmuUnixFile
Get 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:
getPathname
in interfaceEmuUnixFile<T>
- Returns:
- the pathname
-
getStat
Description copied from interface:EmuUnixFile
Get the file'sstat
structure, as defined by the simulator.- Specified by:
getStat
in interfaceEmuUnixFile<T>
- Returns:
- the stat
-
read
Description copied from interface:EmuUnixFile
Read 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:
read
in interfaceEmuUnixFile<T>
- Parameters:
arithmetic
- the arithmeticoffset
- the offsetbuf
- the buffer- Returns:
- the number of bytes read
-
write
Description copied from interface:EmuUnixFile
Write 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:
write
in interfaceEmuUnixFile<T>
- Parameters:
arithmetic
- the arithmeticoffset
- the offsetbuf
- the buffer- Returns:
- the number of bytes written
-
truncate
public void truncate()Description copied from interface:EmuUnixFile
Erase the contents of the file- Specified by:
truncate
in interfaceEmuUnixFile<T>
-