Package ghidra.pcode.emu.unix
Interface EmuUnixFile<T>
- Type Parameters:
T
- the type of values stored in the file
- All Known Implementing Classes:
AbstractEmuUnixFile
,BytesEmuUnixFileSystem.BytesEmuUnixFile
public interface EmuUnixFile<T>
A simulated UNIX file
Contrast this with EmuUnixFileDescriptor
, which is a process's handle to an open file,
not the file itself.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
checkReadable
(EmuUnixUser user) Require the user to have read permission on this file, throwingEmuIOException
if notdefault void
checkWritable
(EmuUnixUser user) Require the user to have write permission on this file, throwingEmuIOException
if notGet the original pathname of this filegetStat()
Get the file'sstat
structure, as defined by the simulator.default boolean
isReadable
(EmuUnixUser user) Check if the given user can read this filedefault boolean
isWritable
(EmuUnixUser user) Check if the given user can write this fileread
(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 buffer
-
Method Details
-
getPathname
String getPathname()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.
- Returns:
- the pathname
-
read
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.- Parameters:
arithmetic
- the arithmeticoffset
- the offsetbuf
- the buffer- Returns:
- the number of bytes read
-
write
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.- Parameters:
arithmetic
- the arithmeticoffset
- the offsetbuf
- the buffer- Returns:
- the number of bytes written
-
truncate
void truncate()Erase the contents of the file -
getStat
EmuUnixFileStat getStat()Get the file'sstat
structure, as defined by the simulator.- Returns:
- the stat
-
isReadable
Check if the given user can read this file- Parameters:
user
- the user- Returns:
- true if permitted, false otherwise
-
isWritable
Check if the given user can write this file- Parameters:
user
- the user- Returns:
- true if permitted, false otherwise
-
checkReadable
Require the user to have read permission on this file, throwingEmuIOException
if not- Parameters:
user
- the user
-
checkWritable
Require the user to have write permission on this file, throwingEmuIOException
if not- Parameters:
user
- the user
-