Package ghidra.pcode.emu.unix
Class DefaultEmuUnixFileHandle<T>
java.lang.Object
ghidra.pcode.emu.unix.DefaultEmuUnixFileHandle<T>
- Type Parameters:
T
- the type of values stored by the file
- All Implemented Interfaces:
EmuUnixFileDescriptor<T>
A file descriptor associated with a file on a simulated UNIX file system
-
Field Summary
Modifier and TypeFieldDescriptionprotected final PcodeArithmetic
<T> protected final EmuUnixFile
<T> protected final Set
<EmuUnixFileSystem.OpenFlag> protected final int
protected final EmuUnixUser
Fields inherited from interface ghidra.pcode.emu.unix.EmuUnixFileDescriptor
FD_STDERR, FD_STDIN, FD_STDOUT
-
Constructor Summary
ConstructorDescriptionDefaultEmuUnixFileHandle
(PcodeMachine<T> machine, CompilerSpec cSpec, EmuUnixFile<T> file, Set<EmuUnixFileSystem.OpenFlag> flags, EmuUnixUser user) Construct a new handle on the given file -
Method Summary
Modifier and TypeMethodDescriptionprotected void
advanceOffset
(T len) Advance the handle's offset (negative to rewind)void
Check if the file is readable, throwingEmuIOException
if notvoid
Check if the file is writable, throwingEmuIOException
if notvoid
close()
Close this descriptorgetFile()
Get the file opened to this handleGet the current offset of the file, or 0 if not applicableRead from the file opened by this handlevoid
See to the given offsetstat()
Obtain thestat
structure of the file opened by this handleRead into the file opened by this handle
-
Field Details
-
arithmetic
-
file
-
flags
-
user
-
offsetBytes
protected final int offsetBytes
-
-
Constructor Details
-
DefaultEmuUnixFileHandle
public DefaultEmuUnixFileHandle(PcodeMachine<T> machine, CompilerSpec cSpec, EmuUnixFile<T> file, Set<EmuUnixFileSystem.OpenFlag> flags, EmuUnixUser user) Construct a new handle on the given file- Parameters:
machine
- the machine emulating the hardwarecSpec
- the ABI of the target platformfile
- the file opened by this handleflags
- the user-specified flags, as defined by the simulatoruser
- the user that opened the file- See Also:
-
-
Method Details
-
getFile
Get the file opened to this handle- Returns:
- the file
-
checkReadable
public void checkReadable()Check if the file is readable, throwingEmuIOException
if not -
checkWritable
public void checkWritable()Check if the file is writable, throwingEmuIOException
if not -
advanceOffset
Advance the handle's offset (negative to rewind)- Parameters:
len
- the number of bytes to advance
-
getOffset
Description copied from interface:EmuUnixFileDescriptor
Get the current offset of the file, or 0 if not applicable- Specified by:
getOffset
in interfaceEmuUnixFileDescriptor<T>
- Returns:
- the offset
-
seek
Description copied from interface:EmuUnixFileDescriptor
See to the given offset- Specified by:
seek
in interfaceEmuUnixFileDescriptor<T>
- Parameters:
offset
- the desired offset- Throws:
EmuIOException
- if an error occurred
-
read
Description copied from interface:EmuUnixFileDescriptor
Read from the file opened by this handle- Specified by:
read
in interfaceEmuUnixFileDescriptor<T>
- Parameters:
buf
- the destination buffer- Returns:
- the number of bytes read
- Throws:
EmuIOException
- if an error occurred
-
write
Description copied from interface:EmuUnixFileDescriptor
Read into the file opened by this handle- Specified by:
write
in interfaceEmuUnixFileDescriptor<T>
- Parameters:
buf
- the source buffer- Returns:
- the number of bytes written
- Throws:
EmuIOException
- if an error occurred
-
stat
Description copied from interface:EmuUnixFileDescriptor
Obtain thestat
structure of the file opened by this handle- Specified by:
stat
in interfaceEmuUnixFileDescriptor<T>
-
close
public void close()Description copied from interface:EmuUnixFileDescriptor
Close this descriptor- Specified by:
close
in interfaceEmuUnixFileDescriptor<T>
-