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
FieldsModifier and TypeFieldDescriptionprotected final PcodeArithmetic<T> protected final EmuUnixFile<T> protected final Set<EmuUnixFileSystem.OpenFlag> protected final intprotected final EmuUnixUserFields inherited from interface ghidra.pcode.emu.unix.EmuUnixFileDescriptor
FD_STDERR, FD_STDIN, FD_STDOUT - 
Constructor Summary
ConstructorsConstructorDescriptionDefaultEmuUnixFileHandle(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 voidadvanceOffset(T len) Advance the handle's offset (negative to rewind)voidCheck if the file is readable, throwingEmuIOExceptionif notvoidCheck if the file is writable, throwingEmuIOExceptionif notvoidclose()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 handlevoidSee to the given offsetstat()Obtain thestatstructure 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, throwingEmuIOExceptionif not - 
checkWritable
public void checkWritable()Check if the file is writable, throwingEmuIOExceptionif not - 
advanceOffset
Advance the handle's offset (negative to rewind)- Parameters:
 len- the number of bytes to advance
 - 
getOffset
Description copied from interface:EmuUnixFileDescriptorGet the current offset of the file, or 0 if not applicable- Specified by:
 getOffsetin interfaceEmuUnixFileDescriptor<T>- Returns:
 - the offset
 
 - 
seek
Description copied from interface:EmuUnixFileDescriptorSee to the given offset- Specified by:
 seekin interfaceEmuUnixFileDescriptor<T>- Parameters:
 offset- the desired offset- Throws:
 EmuIOException- if an error occurred
 - 
read
Description copied from interface:EmuUnixFileDescriptorRead from the file opened by this handle- Specified by:
 readin interfaceEmuUnixFileDescriptor<T>- Parameters:
 buf- the destination buffer- Returns:
 - the number of bytes read
 - Throws:
 EmuIOException- if an error occurred
 - 
write
Description copied from interface:EmuUnixFileDescriptorRead into the file opened by this handle- Specified by:
 writein interfaceEmuUnixFileDescriptor<T>- Parameters:
 buf- the source buffer- Returns:
 - the number of bytes written
 - Throws:
 EmuIOException- if an error occurred
 - 
stat
Description copied from interface:EmuUnixFileDescriptorObtain thestatstructure of the file opened by this handle- Specified by:
 statin interfaceEmuUnixFileDescriptor<T>
 - 
close
public void close()Description copied from interface:EmuUnixFileDescriptorClose this descriptor- Specified by:
 closein interfaceEmuUnixFileDescriptor<T>
 
 -