1 /*
   2  * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 /**
  29  * Win32 APIs constants.
  30  */
  31 
  32 class WindowsConstants {
  33     private WindowsConstants() { }
  34 
  35     // general
  36     public static final long INVALID_HANDLE_VALUE = -1L;
  37 
  38     // generic rights
  39     public static final int GENERIC_READ        = 0x80000000;
  40     public static final int GENERIC_WRITE       = 0x40000000;
  41 
  42     // share modes
  43     public static final int FILE_SHARE_READ     = 0x00000001;
  44     public static final int FILE_SHARE_WRITE    = 0x00000002;
  45     public static final int FILE_SHARE_DELETE   = 0x00000004;
  46 
  47     // creation modes
  48     public static final int CREATE_NEW          = 1;
  49     public static final int CREATE_ALWAYS       = 2;
  50     public static final int OPEN_EXISTING       = 3;
  51     public static final int OPEN_ALWAYS         = 4;
  52     public static final int TRUNCATE_EXISTING   = 5;
  53 
  54     // attributes and flags
  55     public static final int FILE_ATTRIBUTE_READONLY         = 0x00000001;
  56     public static final int FILE_ATTRIBUTE_HIDDEN           = 0x00000002;
  57     public static final int FILE_ATTRIBUTE_SYSTEM           = 0x00000004;
  58     public static final int FILE_ATTRIBUTE_DIRECTORY        = 0x00000010;
  59     public static final int FILE_ATTRIBUTE_ARCHIVE          = 0x00000020;
  60     public static final int FILE_ATTRIBUTE_DEVICE           = 0x00000040;
  61     public static final int FILE_ATTRIBUTE_NORMAL           = 0x00000080;
  62     public static final int FILE_ATTRIBUTE_REPARSE_POINT    = 0x400;
  63     public static final int FILE_FLAG_NO_BUFFERING          = 0x20000000;
  64     public static final int FILE_FLAG_OVERLAPPED            = 0x40000000;
  65     public static final int FILE_FLAG_WRITE_THROUGH         = 0x80000000;
  66     public static final int FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000;
  67     public static final int FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000;
  68     public static final int FILE_FLAG_OPEN_REPARSE_POINT    = 0x00200000;
  69 
  70     // stream ids
  71     public static final int BACKUP_ALTERNATE_DATA           = 0x00000004;
  72     public static final int BACKUP_SPARSE_BLOCK             = 0x00000009;
  73 
  74     // reparse point/symbolic link related constants
  75     public static final int IO_REPARSE_TAG_SYMLINK              = 0xA000000C;
  76     public static final int MAXIMUM_REPARSE_DATA_BUFFER_SIZE    = 16 * 1024;
  77     public static final int SYMBOLIC_LINK_FLAG_DIRECTORY        = 0x1;
  78     public static final int SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2;
  79 
  80     // volume flags
  81     public static final int FILE_CASE_SENSITIVE_SEARCH      = 0x00000001;
  82     public static final int FILE_CASE_PRESERVED_NAMES       = 0x00000002;
  83     public static final int FILE_PERSISTENT_ACLS            = 0x00000008;
  84     public static final int FILE_VOLUME_IS_COMPRESSED       = 0x00008000;
  85     public static final int FILE_NAMED_STREAMS              = 0x00040000;
  86     public static final int FILE_READ_ONLY_VOLUME           = 0x00080000;
  87 
  88     // error codes
  89     public static final int ERROR_FILE_NOT_FOUND        = 2;
  90     public static final int ERROR_PATH_NOT_FOUND        = 3;
  91     public static final int ERROR_ACCESS_DENIED         = 5;
  92     public static final int ERROR_INVALID_HANDLE        = 6;
  93     public static final int ERROR_INVALID_DATA          = 13;
  94     public static final int ERROR_NOT_SAME_DEVICE       = 17;
  95     public static final int ERROR_NOT_READY             = 21;
  96     public static final int ERROR_SHARING_VIOLATION     = 32;
  97     public static final int ERROR_FILE_EXISTS           = 80;
  98     public static final int ERROR_INVALID_PARAMETER     = 87;
  99     public static final int ERROR_DISK_FULL             = 112;
 100     public static final int ERROR_INSUFFICIENT_BUFFER   = 122;
 101     public static final int ERROR_INVALID_LEVEL         = 124;
 102     public static final int ERROR_DIR_NOT_ROOT          = 144;
 103     public static final int ERROR_DIR_NOT_EMPTY         = 145;
 104     public static final int ERROR_ALREADY_EXISTS        = 183;
 105     public static final int ERROR_MORE_DATA             = 234;
 106     public static final int ERROR_DIRECTORY             = 267;
 107     public static final int ERROR_NOTIFY_ENUM_DIR       = 1022;
 108     public static final int ERROR_PRIVILEGE_NOT_HELD    = 1314;
 109     public static final int ERROR_NONE_MAPPED           = 1332;
 110     public static final int ERROR_NOT_A_REPARSE_POINT   = 4390;
 111     public static final int ERROR_INVALID_REPARSE_DATA  = 4392;
 112 
 113     // notify filters
 114     public static final int FILE_NOTIFY_CHANGE_FILE_NAME   = 0x00000001;
 115     public static final int FILE_NOTIFY_CHANGE_DIR_NAME    = 0x00000002;
 116     public static final int FILE_NOTIFY_CHANGE_ATTRIBUTES  = 0x00000004;
 117     public static final int FILE_NOTIFY_CHANGE_SIZE        = 0x00000008;
 118     public static final int FILE_NOTIFY_CHANGE_LAST_WRITE  = 0x00000010;
 119     public static final int FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x00000020;
 120     public static final int FILE_NOTIFY_CHANGE_CREATION    = 0x00000040;
 121     public static final int FILE_NOTIFY_CHANGE_SECURITY    = 0x00000100;
 122 
 123     // notify actions
 124     public static final int FILE_ACTION_ADDED              = 0x00000001;
 125     public static final int FILE_ACTION_REMOVED            = 0x00000002;
 126     public static final int FILE_ACTION_MODIFIED           = 0x00000003;
 127     public static final int FILE_ACTION_RENAMED_OLD_NAME   = 0x00000004;
 128     public static final int FILE_ACTION_RENAMED_NEW_NAME   = 0x00000005;
 129 
 130     // copy flags
 131     public static final int COPY_FILE_FAIL_IF_EXISTS       = 0x00000001;
 132     public static final int COPY_FILE_COPY_SYMLINK         = 0x00000800;
 133 
 134     // move flags
 135     public static final int MOVEFILE_REPLACE_EXISTING       = 0x00000001;
 136     public static final int MOVEFILE_COPY_ALLOWED           = 0x00000002;
 137 
 138     // drive types
 139     public static final int DRIVE_UNKNOWN                   = 0;
 140     public static final int DRIVE_NO_ROOT_DIR               = 1;
 141     public static final int DRIVE_REMOVABLE                 = 2;
 142     public static final int DRIVE_FIXED                     = 3;
 143     public static final int DRIVE_REMOTE                    = 4;
 144     public static final int DRIVE_CDROM                     = 5;
 145     public static final int DRIVE_RAMDISK                   = 6;
 146 
 147     // file security
 148     public static final int OWNER_SECURITY_INFORMATION      = 0x00000001;
 149     public static final int GROUP_SECURITY_INFORMATION      = 0x00000002;
 150     public static final int DACL_SECURITY_INFORMATION       = 0x00000004;
 151     public static final int SACL_SECURITY_INFORMATION       = 0x00000008;
 152 
 153     public static final int SidTypeUser = 1;
 154     public static final int SidTypeGroup = 2;
 155     public static final int SidTypeDomain = 3;
 156     public static final int SidTypeAlias = 4;
 157     public static final int SidTypeWellKnownGroup = 5;
 158     public static final int SidTypeDeletedAccount = 6;
 159     public static final int SidTypeInvalid = 7;
 160     public static final int SidTypeUnknown = 8;
 161     public static final int SidTypeComputer= 9;
 162 
 163     public static final byte ACCESS_ALLOWED_ACE_TYPE         = 0x0;
 164     public static final byte ACCESS_DENIED_ACE_TYPE          = 0x1;
 165 
 166     public static final byte OBJECT_INHERIT_ACE              = 0x1;
 167     public static final byte CONTAINER_INHERIT_ACE           = 0x2;
 168     public static final byte NO_PROPAGATE_INHERIT_ACE        = 0x4;
 169     public static final byte INHERIT_ONLY_ACE                = 0x8;
 170 
 171     public static final int DELETE                      = 0x00010000;
 172     public static final int READ_CONTROL                = 0x00020000;
 173     public static final int WRITE_DAC                   = 0x00040000;
 174     public static final int WRITE_OWNER                 = 0x00080000;
 175     public static final int SYNCHRONIZE                 = 0x00100000;
 176 
 177     public static final int FILE_LIST_DIRECTORY         = 0x0001;
 178     public static final int FILE_READ_DATA              = 0x0001;
 179     public static final int FILE_WRITE_DATA             = 0x0002;
 180     public static final int FILE_APPEND_DATA            = 0x0004;
 181     public static final int FILE_READ_EA                = 0x0008;
 182     public static final int FILE_WRITE_EA               = 0x0010;
 183     public static final int FILE_EXECUTE                = 0x0020;
 184     public static final int FILE_DELETE_CHILD           = 0x0040;
 185     public static final int FILE_READ_ATTRIBUTES        = 0x0080;
 186     public static final int FILE_WRITE_ATTRIBUTES       = 0x0100;
 187 
 188     public static final int FILE_GENERIC_READ           = 0x00120089;
 189     public static final int FILE_GENERIC_WRITE          = 0x00120116;
 190     public static final int FILE_GENERIC_EXECUTE        = 0x001200a0;
 191     public static final int FILE_ALL_ACCESS             = 0x001f01ff;
 192 
 193     // operating system security
 194     public static final int TOKEN_DUPLICATE             = 0x0002;
 195     public static final int TOKEN_IMPERSONATE           = 0x0004;
 196     public static final int TOKEN_QUERY                 = 0x0008;
 197     public static final int TOKEN_ADJUST_PRIVILEGES     = 0x0020;
 198 
 199     public static final int SE_PRIVILEGE_ENABLED        = 0x00000002;
 200 
 201     public static final int TokenUser                   = 1;
 202     public static final int PROCESS_QUERY_INFORMATION   = 0x0400;
 203 }