01: /* Copyright (c) 2007 Timothy Wall, All Rights Reserved
02: *
03: * This library is free software; you can redistribute it and/or
04: * modify it under the terms of the GNU Lesser General Public
05: * License as published by the Free Software Foundation; either
06: * version 2.1 of the License, or (at your option) any later version.
07: * <p/>
08: * This library is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: */
13: package org.netbeans.core.nativeaccess.transparency.win32;
14:
15: import com.sun.jna.Native;
16: import com.sun.jna.Pointer;
17: import com.sun.jna.Structure;
18:
19: /** Mapping for w32 Shell API.
20: * Note that the C header "shellapi.h" includes "pshpack1.h", which disables
21: * automatic alignment of structure fields.
22: */
23: public interface Shell32 extends W32API {
24:
25: /** Custom alignment of structures. */
26: int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE;
27: Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32",
28: Shell32.class, DEFAULT_OPTIONS);
29:
30: int FO_MOVE = 1;
31: int FO_COPY = 2;
32: int FO_DELETE = 3;
33: int FO_RENAME = 4;
34:
35: int FOF_MULTIDESTFILES = 1;
36: int FOF_CONFIRMMOUSE = 2;
37: int FOF_SILENT = 4;
38: int FOF_RENAMEONCOLLISION = 8;
39: int FOF_NOCONFIRMATION = 16;
40: int FOF_WANTMAPPINGHANDLE = 32;
41: int FOF_ALLOWUNDO = 64;
42: int FOF_FILESONLY = 128;
43: int FOF_SIMPLEPROGRESS = 256;
44: int FOF_NOCONFIRMMKDIR = 512;
45: int FOF_NOERRORUI = 1024;
46: int FOF_NOCOPYSECURITYATTRIBS = 2048;
47:
48: public static class SHFILEOPSTRUCT extends Structure {
49: public HANDLE hwnd;
50: public int wFunc;
51: public String pFrom;
52: public String pTo;
53: public short fFlags;
54: public boolean fAnyOperationsAborted;
55: public Pointer pNameMappings;
56: public String lpszProgressTitle;
57:
58: /** Use this to encode <code>pFrom/pTo</code> paths. */
59: public String encodePaths(String[] paths) {
60: String encoded = "";
61: for (int i = 0; i < paths.length; i++) {
62: encoded += paths[i];
63: encoded += "\0";
64: }
65: return encoded + "\0";
66: }
67: }
68:
69: int SHFileOperation(SHFILEOPSTRUCT fileop);
70: }
|