public class WindowsShortcut extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
isDirectory |
private boolean |
isLocal |
private java.lang.String |
realFile |
Constructor and Description |
---|
WindowsShortcut(java.io.File file)
Constructs a new
WindowsShortcut |
Modifier and Type | Method and Description |
---|---|
private static int |
bytesToDword(byte[] bytes,
int off) |
private static int |
bytesToWord(byte[] bytes,
int off) |
private static byte[] |
getBytes(java.io.InputStream in)
Gets all the bytes from an InputStream
|
private static byte[] |
getBytes(java.io.InputStream in,
java.lang.Integer max)
Gets up to max bytes from an InputStream
|
private static java.lang.String |
getNullDelimitedString(byte[] bytes,
int off) |
java.lang.String |
getRealFilename() |
boolean |
isDirectory()
Tests if the shortcut points to a directory.
|
boolean |
isLocal()
Tests if the shortcut points to a local resource.
|
private static boolean |
isMagicPresent(byte[] link) |
static boolean |
isPotentialValidLink(java.io.File file)
Provides a quick test to see if this could be a valid link !
If you try to instantiate a new WindowShortcut and the link is not valid,
Exceptions may be thrown and Exceptions are extremely slow to generate,
therefore any code needing to loop through several files should first check this.
|
private void |
parseLink(byte[] link)
Gobbles up link data by parsing it and storing info in member fields
|
private boolean isDirectory
private boolean isLocal
private java.lang.String realFile
public WindowsShortcut(java.io.File file) throws java.io.IOException, java.text.ParseException
WindowsShortcut
file
- filejava.io.IOException
- if an I/O error occursjava.text.ParseException
- if a parsing error occurspublic static boolean isPotentialValidLink(java.io.File file) throws java.io.IOException
file
- the potential linkjava.io.IOException
- if an IOException is thrown while reading from the filepublic java.lang.String getRealFilename()
public boolean isLocal()
public boolean isDirectory()
private static byte[] getBytes(java.io.InputStream in) throws java.io.IOException
in
- the InputStream from which to read bytesjava.io.IOException
- if an IOException is encountered while reading the data from the InputStreamprivate static byte[] getBytes(java.io.InputStream in, java.lang.Integer max) throws java.io.IOException
in
- the InputStream from which to read bytesmax
- maximum number of bytes to readjava.io.IOException
- if an IOException is encountered while reading the data from the InputStreamprivate static boolean isMagicPresent(byte[] link)
private void parseLink(byte[] link) throws java.text.ParseException
link
- all the bytes from the .lnk filejava.text.ParseException
- if a parsing error occursprivate static java.lang.String getNullDelimitedString(byte[] bytes, int off)
private static int bytesToWord(byte[] bytes, int off)
private static int bytesToDword(byte[] bytes, int off)