I'm getting an error message trying to call the Windows GetFileAttributes()
function (I'm running Windows XP). Can anyone see what I'm doing wrong?
ERROR MESSAGE:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up
function 'GetFileAttributes': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:129)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:250)
at com.sun.jna.Library$Handler.invoke(Library.java:191)
at $Proxy0.GetFileAttributes(Unknown Source)
at com.atomware.Publisher.accept(Publisher.java:70)
at com.atomware.io.Directory.accept(Directory.java:80)
at java.io.File.listFiles(Unknown Source)
at com.atomware.io.Directory.getMatchingFiles(Directory.java:107)
at com.atomware.io.TreeWalker.walk(TreeWalker.java:53)
at com.atomware.Publisher.publish(Publisher.java:87)
at com.atomware.Publisher.main(Publisher.java:33)
CODE:
import java.io.File;
import com.sun.jna.Native;
import com.sun.jna.win32.StdCallLibrary;
/**
* Provides access to the Microsoft Windows KERNEL32.DLL.
*/
public class WindowsKernel {
//==============================================================================================
/**
* Accesses native Windows API from Java
*/
public interface API extends StdCallLibrary {
/** The API Instance */
API INSTANCE = (API)Native.loadLibrary(LIBRARY_NAME, API.class);
/**
* Retrieves a set of FAT file system attributes for a specified file or
directory.
* Many file attributes are already from the Java {@link File} class, but
certain ones,
* such as the archive bit, are available only by calling this method.
* @param fileName The file name.
* @return The bit-mapped attributes.
*/
int GetFileAttributes(String fileName);
}
//==============================================================================================
/** Value: {@value} */
public static final String LIBRARY_NAME = "C:/WINDOWS/SYSTEM32/kernel32.dll";
}