Source Code Cross Referenced for SmbComOpenAndX.java in  » Groupware » hipergate » com » knowgate » jcifs » smb » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.jcifs.smb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* jcifs smb client library in Java
002:         * Copyright (C) 2000  "Michael B. Allen" <jcifs at samba dot org>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.knowgate.jcifs.smb;
020:
021:        import java.util.Date;
022:        import java.io.IOException;
023:        import java.io.InputStream;
024:
025:        import com.knowgate.jcifs.Config;
026:        import com.knowgate.misc.Gadgets;
027:
028:        class SmbComOpenAndX extends AndXServerMessageBlock {
029:
030:            // flags (not the same as flags constructor argument)
031:            private static final int FLAGS_RETURN_ADDITIONAL_INFO = 0x01;
032:            private static final int FLAGS_REQUEST_OPLOCK = 0x02;
033:            private static final int FLAGS_REQUEST_BATCH_OPLOCK = 0x04;
034:
035:            // Access Mode Encoding for desiredAccess
036:            private static final int SHARING_COMPATIBILITY = 0x00;
037:            private static final int SHARING_DENY_READ_WRITE_EXECUTE = 0x10;
038:            private static final int SHARING_DENY_WRITE = 0x20;
039:            private static final int SHARING_DENY_READ_EXECUTE = 0x30;
040:            private static final int SHARING_DENY_NONE = 0x40;
041:
042:            private static final int DO_NOT_CACHE = 0x1000; // bit 12
043:            private static final int WRITE_THROUGH = 0x4000; // bit 14
044:
045:            private static final int OPEN_FN_CREATE = 0x10;
046:            private static final int OPEN_FN_FAIL_IF_EXISTS = 0x00;
047:            private static final int OPEN_FN_OPEN = 0x01;
048:            private static final int OPEN_FN_TRUNC = 0x02;
049:
050:            private static final int BATCH_LIMIT = Config.getInt(
051:                    "jcifs.smb.client.OpenAndX.ReadAndX", 1);
052:
053:            int flags, desiredAccess, searchAttributes, fileAttributes,
054:                    creationTime, openFunction, allocationSize;
055:
056:            // flags is NOT the same as flags member
057:
058:            SmbComOpenAndX(String fileName, int flags, ServerMessageBlock andx) {
059:                super (andx);
060:                this .path = fileName;
061:                command = SMB_COM_OPEN_ANDX;
062:
063:                // desiredAccess
064:                desiredAccess = (flags >>> 16) & 0x3;
065:                if (desiredAccess == 0x3) {
066:                    desiredAccess = 0x2; /* Mmm, I thought 0x03 was RDWR */
067:                }
068:                desiredAccess |= SHARING_DENY_NONE;
069:                desiredAccess &= ~0x1; // Win98 doesn't like GENERIC_READ ?! -- get Access Denied.
070:
071:                // searchAttributes
072:                searchAttributes = ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM;
073:
074:                // fileAttributes
075:                fileAttributes = 0;
076:
077:                // openFunction
078:                if ((flags & SmbFile.O_TRUNC) == SmbFile.O_TRUNC) {
079:                    // truncate the file
080:                    if ((flags & SmbFile.O_CREAT) == SmbFile.O_CREAT) {
081:                        // create it if necessary
082:                        openFunction = OPEN_FN_TRUNC | OPEN_FN_CREATE;
083:                    } else {
084:                        openFunction = OPEN_FN_TRUNC;
085:                    }
086:                } else {
087:                    // don't truncate the file
088:                    if ((flags & SmbFile.O_CREAT) == SmbFile.O_CREAT) {
089:                        // create it if necessary
090:                        if ((flags & SmbFile.O_EXCL) == SmbFile.O_EXCL) {
091:                            // fail if already exists
092:                            openFunction = OPEN_FN_CREATE
093:                                    | OPEN_FN_FAIL_IF_EXISTS;
094:                        } else {
095:                            openFunction = OPEN_FN_CREATE | OPEN_FN_OPEN;
096:                        }
097:                    } else {
098:                        openFunction = OPEN_FN_OPEN;
099:                    }
100:                }
101:            }
102:
103:            int getBatchLimit(byte command) {
104:                return command == SMB_COM_READ_ANDX ? BATCH_LIMIT : 0;
105:            }
106:
107:            int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
108:                int start = dstIndex;
109:
110:                writeInt2(flags, dst, dstIndex);
111:                dstIndex += 2;
112:                writeInt2(desiredAccess, dst, dstIndex);
113:                dstIndex += 2;
114:                writeInt2(searchAttributes, dst, dstIndex);
115:                dstIndex += 2;
116:                writeInt2(fileAttributes, dst, dstIndex);
117:                dstIndex += 2;
118:                creationTime = 0;
119:                writeInt4(creationTime, dst, dstIndex);
120:                dstIndex += 4;
121:                writeInt2(openFunction, dst, dstIndex);
122:                dstIndex += 2;
123:                writeInt4(allocationSize, dst, dstIndex);
124:                dstIndex += 4;
125:                for (int i = 0; i < 8; i++) {
126:                    dst[dstIndex++] = 0x00;
127:                }
128:
129:                return dstIndex - start;
130:            }
131:
132:            int writeBytesWireFormat(byte[] dst, int dstIndex) {
133:                int start = dstIndex;
134:
135:                if (useUnicode) {
136:                    dst[dstIndex++] = (byte) '\0';
137:                }
138:                dstIndex += writeString(path, dst, dstIndex);
139:
140:                return dstIndex - start;
141:            }
142:
143:            int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
144:                return 0;
145:            }
146:
147:            int readBytesWireFormat(byte[] buffer, int bufferIndex) {
148:                return 0;
149:            }
150:
151:            int readBytesDirectWireFormat(InputStream in, int byteCount,
152:                    byte[] buffer, int bufferIndex) throws IOException {
153:                return 0;
154:            }
155:
156:            public String toString() {
157:                return new String("SmbComOpenAndX[" + super .toString()
158:                        + ",flags=0x" + Gadgets.toHexString(flags, 2)
159:                        + ",desiredAccess=0x"
160:                        + Gadgets.toHexString(desiredAccess, 4)
161:                        + ",searchAttributes=0x"
162:                        + Gadgets.toHexString(searchAttributes, 4)
163:                        + ",fileAttributes=0x"
164:                        + Gadgets.toHexString(fileAttributes, 4)
165:                        + ",creationTime=" + new Date(creationTime)
166:                        + ",openFunction=0x"
167:                        + Gadgets.toHexString(openFunction, 2)
168:                        + ",allocationSize=" + allocationSize + ",fileName="
169:                        + path + "]");
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.