/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Windows emulation of NamedAttributeView using Alternative Data Streams
*/
{
// syntax to address named streams
throw new NullPointerException("'name' is null");
}
}
private final boolean followLinks;
this.followLinks = followLinks;
}
// enumerates the file streams using FindFirstStream/FindNextStream APIs.
try {
try {
// first stream is always ::$DATA for files
}
}
} finally {
}
}
} catch (WindowsException x) {
}
}
// enumerates the file streams by reading the stream headers using
// BackupRead
long handle = -1L;
try {
int flags = FILE_FLAG_BACKUP_SEMANTICS;
FILE_SHARE_READ, // no write as we depend on file size
flags);
} catch (WindowsException x) {
}
// buffer to read stream header and stream name.
final int BUFFER_SIZE = 4096;
// result with names of alternative data streams
try {
/**
* typedef struct _WIN32_STREAM_ID {
* DWORD dwStreamId;
* DWORD dwStreamAttributes;
* LARGE_INTEGER Size;
* DWORD dwStreamNameSize;
* WCHAR cStreamName[ANYSIZE_ARRAY];
* } WIN32_STREAM_ID;
*/
final int SIZEOF_STREAM_HEADER = 20;
final int OFFSETOF_STREAM_ID = 0;
final int OFFSETOF_STREAM_SIZE = 8;
final int OFFSETOF_STREAM_NAME_SIZE = 16;
long context = 0L;
try {
for (;;) {
// read stream header
SIZEOF_STREAM_HEADER, false, context);
break;
// read stream name
if (nameSize > 0) {
break;
}
// check for alternative data stream
if (streamId == BACKUP_ALTERNATE_DATA) {
}
// sparse blocks not currently handled as documentation
// is not sufficient on how the spase block can be skipped.
if (streamId == BACKUP_SPARSE_BLOCK) {
throw new IOException("Spare blocks not handled");
}
// seek to end of stream
if (streamSize > 0L) {
}
}
} catch (WindowsException x) {
// failed to read or seek
throw new IOException(x.errorString());
} finally {
// release context
if (context != 0L) {
try {
} catch (WindowsException ignore) { }
}
}
} finally {
}
}
// use stream APIs on Windwos Server 2003 and newer
return listUsingStreamEnumeration();
} else {
return listUsingBackupRead();
}
}
// wrap with channel
try {
if (!followLinks)
} catch (WindowsException x) {
}
try {
throw new ArithmeticException("Stream too large");
return (int)size;
} finally {
}
}
// wrap with channel
try {
if (!followLinks)
} catch (WindowsException x) {
}
// read to EOF (nothing we can do if I/O error occurs)
try {
throw new IOException("Stream too large");
int total = 0;
while (dst.hasRemaining()) {
if (n < 0)
break;
total += n;
}
return total;
} finally {
}
}
/**
* Creating a named stream will cause the unnamed stream to be created
* if it doesn't already exist. To avoid this we open the unnamed stream
* replace the named stream. Opening the file without sharing options
* may cause sharing violations with other programs that are accessing
* the unnamed stream.
*/
long handle = -1L;
try {
int flags = FILE_FLAG_BACKUP_SEMANTICS;
if (!followLinks)
flags);
} catch (WindowsException x) {
}
try {
if (!followLinks)
try {
} catch (WindowsException x) {
}
// write value (nothing we can do if I/O error occurs)
try {
while (src.hasRemaining()) {
}
return rem;
} finally {
}
} finally {
}
}
try {
} catch (WindowsException x) {
}
}
}