本文整理汇总了C++中JNU_ThrowIOExceptionWithLastError函数的典型用法代码示例。如果您正苦于以下问题:C++ JNU_ThrowIOExceptionWithLastError函数的具体用法?C++ JNU_ThrowIOExceptionWithLastError怎么用?C++ JNU_ThrowIOExceptionWithLastError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JNU_ThrowIOExceptionWithLastError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Java_sun_nio_ch_FileDispatcherImpl_read0
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_read0(JNIEnv *env, jclass clazz, jobject fdo,
jlong address, jint len)
{
DWORD read = 0;
BOOL result = 0;
HANDLE h = (HANDLE)(handleval(env, fdo));
if (h == INVALID_HANDLE_VALUE) {
JNU_ThrowIOExceptionWithLastError(env, "Invalid handle");
return IOS_THROWN;
}
result = ReadFile(h, /* File handle to read */
(LPVOID)address, /* address to put data */
len, /* number of bytes to read */
&read, /* number of bytes read */
NULL); /* no overlapped struct */
if (result == 0) {
int error = GetLastError();
if (error == ERROR_BROKEN_PIPE) {
return IOS_EOF;
}
if (error == ERROR_NO_DATA) {
return IOS_UNAVAILABLE;
}
JNU_ThrowIOExceptionWithLastError(env, "Read failed");
return IOS_THROWN;
}
return convertReturnVal(env, (jint)read, JNI_TRUE);
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:30,代码来源:FileDispatcherImpl.c
示例2: Java_sun_nio_ch_FileDispatcherImpl_pwrite0
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_pwrite0(JNIEnv *env, jclass clazz, jobject fdo,
jlong address, jint len, jlong offset)
{
BOOL result = 0;
DWORD written = 0;
HANDLE h = (HANDLE)(handleval(env, fdo));
DWORD lowPos = 0;
long highPos = 0;
DWORD lowOffset = 0;
long highOffset = 0;
lowPos = SetFilePointer(h, 0, &highPos, FILE_CURRENT);
if (lowPos == ((DWORD)-1)) {
if (GetLastError() != ERROR_SUCCESS) {
JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
return IOS_THROWN;
}
}
lowOffset = (DWORD)offset;
highOffset = (DWORD)(offset >> 32);
lowOffset = SetFilePointer(h, lowOffset, &highOffset, FILE_BEGIN);
if (lowOffset == ((DWORD)-1)) {
if (GetLastError() != ERROR_SUCCESS) {
JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
return IOS_THROWN;
}
}
result = WriteFile(h, /* File handle to write */
(LPCVOID)address, /* pointers to the buffers */
len, /* number of bytes to write */
&written, /* receives number of bytes written */
NULL); /* no overlapped struct */
if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
return IOS_THROWN;
}
lowPos = SetFilePointer(h, lowPos, &highPos, FILE_BEGIN);
if (lowPos == ((DWORD)-1)) {
if (GetLastError() != ERROR_SUCCESS) {
JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
return IOS_THROWN;
}
}
return convertReturnVal(env, (jint)written, JNI_FALSE);
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:51,代码来源:FileDispatcherImpl.c
示例3: isAccessUserOnly
/*
* Returns JNI_TRUE if the specified owner is the only SID will access
* to the file.
*/
static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
ACL_SIZE_INFORMATION acl_size_info;
DWORD i;
/*
* If there's no DACL then there's no access to the file
*/
if (acl == NULL) {
return JNI_TRUE;
}
/*
* Get the ACE count
*/
if (!GetAclInformation(acl, (void *) &acl_size_info, sizeof(acl_size_info),
AclSizeInformation)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAclInformation failed");
return JNI_FALSE;
}
/*
* Iterate over the ACEs. For each "allow" type check that the SID
* matches the owner, and check that the access is read only.
*/
for (i = 0; i < acl_size_info.AceCount; i++) {
void* ace;
ACCESS_ALLOWED_ACE *access;
SID* sid;
if (!GetAce(acl, i, &ace)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAce failed");
return -1;
}
if (((ACCESS_ALLOWED_ACE *)ace)->Header.AceType != ACCESS_ALLOWED_ACE_TYPE) {
continue;
}
access = (ACCESS_ALLOWED_ACE *)ace;
sid = (SID *) &access->SidStart;
if (!EqualSid(owner, sid)) {
/*
* If the ACE allows any access then the file is not secure.
*/
if (access->Mask & ANY_ACCESS) {
return JNI_FALSE;
}
}
}
return JNI_TRUE;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:53,代码来源:FileSystemImpl.c
示例4: sizeof
/*
* Class: sun_management_FileSystemImpl
* Method: init0
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_management_FileSystemImpl_init0
(JNIEnv *env, jclass ignored)
{
OSVERSIONINFO ver;
HINSTANCE hInst;
/*
* Get the OS version. If dwPlatformId is VER_PLATFORM_WIN32_NT
* it means we're running on a Windows NT, 2000, or XP machine.
*/
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
isNT = (ver.dwPlatformId == VER_PLATFORM_WIN32_NT);
if (!isNT) {
return;
}
/*
* On NT/2000/XP we need the addresses of the security functions
*/
hInst = LoadLibrary("ADVAPI32.DLL");
if (hInst == NULL) {
JNU_ThrowIOExceptionWithLastError(env, "Unable to load ADVAPI32.DLL");
return;
}
GetFileSecurity_func = (GetFileSecurityFunc)GetProcAddress(hInst, "GetFileSecurityA");
GetSecurityDescriptorOwner_func =
(GetSecurityDescriptorOwnerFunc)GetProcAddress(hInst, "GetSecurityDescriptorOwner");
GetSecurityDescriptorDacl_func =
(GetSecurityDescriptorDaclFunc)GetProcAddress(hInst, "GetSecurityDescriptorDacl");
GetAclInformation_func =
(GetAclInformationFunc)GetProcAddress(hInst, "GetAclInformation");
GetAce_func = (GetAceFunc)GetProcAddress(hInst, "GetAce");
EqualSid_func = (EqualSidFunc)GetProcAddress(hInst, "EqualSid");
if (GetFileSecurity_func == NULL ||
GetSecurityDescriptorDacl_func == NULL ||
GetSecurityDescriptorDacl_func == NULL ||
GetAclInformation_func == NULL ||
GetAce_func == NULL ||
EqualSid_func == NULL)
{
JNU_ThrowIOExceptionWithLastError(env,
"Unable to get address of security functions");
return;
}
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:54,代码来源:FileSystemImpl.c
示例5: Java_sun_nio_ch_FileDispatcherImpl_readv0
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_FileDispatcherImpl_readv0(JNIEnv *env, jclass clazz, jobject fdo,
jlong address, jint len)
{
DWORD read = 0;
BOOL result = 0;
jlong totalRead = 0;
LPVOID loc;
int i = 0;
DWORD num = 0;
struct iovec *iovecp = (struct iovec *)jlong_to_ptr(address);
HANDLE h = (HANDLE)(handleval(env, fdo));
if (h == INVALID_HANDLE_VALUE) {
JNU_ThrowIOExceptionWithLastError(env, "Invalid handle");
return IOS_THROWN;
}
for(i=0; i<len; i++) {
loc = (LPVOID)jlong_to_ptr(iovecp[i].iov_base);
num = iovecp[i].iov_len;
result = ReadFile(h, /* File handle to read */
loc, /* address to put data */
num, /* number of bytes to read */
&read, /* number of bytes read */
NULL); /* no overlapped struct */
if (read > 0) {
totalRead += read;
}
if (read < num) {
break;
}
}
if (result == 0) {
int error = GetLastError();
if (error == ERROR_BROKEN_PIPE) {
return IOS_EOF;
}
if (error == ERROR_NO_DATA) {
return IOS_UNAVAILABLE;
}
JNU_ThrowIOExceptionWithLastError(env, "Read failed");
return IOS_THROWN;
}
return convertLongReturnVal(env, totalRead, JNI_TRUE);
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:48,代码来源:FileDispatcherImpl.c
示例6: JNU_ThrowIOExceptionWithLastError
/*
* Class: sun_tools_attach_VirtualMachineImpl
* Method: sigquit
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_sigquit
(JNIEnv *env, jclass cls, jint pid)
{
if (kill((pid_t)pid, SIGQUIT) == -1) {
JNU_ThrowIOExceptionWithLastError(env, "kill");
}
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:12,代码来源:VirtualMachineImpl.c
示例7: Java_sun_nio_ch_FileDispatcherImpl_write0
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_write0(JNIEnv *env, jclass clazz, jobject fdo,
jlong address, jint len, jboolean append)
{
BOOL result = 0;
DWORD written = 0;
HANDLE h = (HANDLE)(handleval(env, fdo));
if (h != INVALID_HANDLE_VALUE) {
OVERLAPPED ov;
LPOVERLAPPED lpOv;
if (append == JNI_TRUE) {
ov.Offset = (DWORD)0xFFFFFFFF;
ov.OffsetHigh = (DWORD)0xFFFFFFFF;
ov.hEvent = NULL;
lpOv = &ov;
} else {
lpOv = NULL;
}
result = WriteFile(h, /* File handle to write */
(LPCVOID)address, /* pointers to the buffers */
len, /* number of bytes to write */
&written, /* receives number of bytes written */
lpOv); /* overlapped struct */
}
if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
}
return convertReturnVal(env, (jint)written, JNI_FALSE);
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:32,代码来源:FileDispatcherImpl.c
示例8: Java_sun_tools_attach_BsdVirtualMachine_createAttachFile
/*
* Class: sun_tools_attach_BSDVirtualMachine
* Method: createAttachFile
* Signature: (Ljava.lang.String;)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_BsdVirtualMachine_createAttachFile(JNIEnv *env, jclass cls, jstring path)
{
const char* _path;
jboolean isCopy;
int fd, rc;
_path = GetStringPlatformChars(env, path, &isCopy);
if (_path == NULL) {
JNU_ThrowIOException(env, "Must specify a path");
return;
}
RESTARTABLE(open(_path, O_CREAT | O_EXCL, S_IWUSR | S_IRUSR), fd);
if (fd == -1) {
/* release p here before we throw an I/O exception */
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, _path);
}
JNU_ThrowIOExceptionWithLastError(env, "open");
return;
}
RESTARTABLE(chown(_path, geteuid(), getegid()), rc);
RESTARTABLE(close(fd), rc);
/* release p here */
if (isCopy) {
JNU_ReleaseStringPlatformChars(env, path, _path);
}
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:36,代码来源:BsdVirtualMachine.c
示例9: Java_sun_nio_ch_InheritedChannel_close0
JNIEXPORT void JNICALL
Java_sun_nio_ch_InheritedChannel_close0(JNIEnv *env, jclass cla, jint fd)
{
if (close(fd) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "close failed");
}
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:7,代码来源:InheritedChannel.c
示例10: Java_sun_nio_ch_InheritedChannel_open0
JNIEXPORT jint JNICALL
Java_sun_nio_ch_InheritedChannel_open0(JNIEnv *env, jclass cla, jstring path, jint oflag)
{
const char* str;
int oflag_actual;
/* convert to OS specific value */
switch (oflag) {
case sun_nio_ch_InheritedChannel_O_RDWR :
oflag_actual = O_RDWR;
break;
case sun_nio_ch_InheritedChannel_O_RDONLY :
oflag_actual = O_RDONLY;
break;
case sun_nio_ch_InheritedChannel_O_WRONLY :
oflag_actual = O_WRONLY;
break;
default :
JNU_ThrowInternalError(env, "Unrecognized file mode");
return -1;
}
str = JNU_GetStringPlatformChars(env, path, NULL);
if (str == NULL) {
return (jint)-1;
} else {
int fd = open(str, oflag_actual);
if (fd < 0) {
JNU_ThrowIOExceptionWithLastError(env, str);
}
JNU_ReleaseStringPlatformChars(env, path, str);
return (jint)fd;
}
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:34,代码来源:InheritedChannel.c
示例11: Java_sun_nio_ch_InheritedChannel_dup2
JNIEXPORT void JNICALL
Java_sun_nio_ch_InheritedChannel_dup2(JNIEnv *env, jclass cla, jint fd, jint fd2)
{
if (dup2(fd, fd2) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
}
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:7,代码来源:InheritedChannel.c
示例12: Java_sun_nio_ch_IOUtil_configureBlocking
JNIEXPORT void JNICALL
Java_sun_nio_ch_IOUtil_configureBlocking(JNIEnv *env, jclass clazz,
jobject fdo, jboolean blocking)
{
if (configureBlocking(fdval(env, fdo), blocking) < 0)
JNU_ThrowIOExceptionWithLastError(env, "Configure blocking failed");
}
开发者ID:digideskio,项目名称:openjdk-fontfix,代码行数:7,代码来源:IOUtil.c
示例13: Java_sun_net_sdp_SdpSupport_convert0
/**
* Converts an existing file descriptor, that references an unbound TCP socket,
* to SDP.
*/
JNIEXPORT void JNICALL
Java_sun_net_sdp_SdpSupport_convert0(JNIEnv *env, jclass cls, int fd)
{
int s = create(env);
if (s >= 0) {
socklen_t len;
int arg, res;
struct linger linger;
/* copy socket options that are relevant to SDP */
len = sizeof(arg);
if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, &len) == 0)
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, len);
len = sizeof(arg);
if (getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, &len) == 0)
setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, len);
len = sizeof(linger);
if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (void*)&linger, &len) == 0)
setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, len);
RESTARTABLE(dup2(s, fd), res);
if (res < 0)
JNU_ThrowIOExceptionWithLastError(env, "dup2");
RESTARTABLE(close(s), res);
}
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:30,代码来源:SdpSupport.c
示例14: closeFileDescriptor
static void closeFileDescriptor(JNIEnv *env, int fd) {
if (fd != -1) {
int result = close(fd);
if (result < 0)
JNU_ThrowIOExceptionWithLastError(env, "Close failed");
}
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:7,代码来源:FileDispatcher.c
示例15: create
/**
* Creates a SDP socket.
*/
static int create(JNIEnv* env)
{
int s;
#if defined(__solaris__)
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
s = socket(domain, SOCK_STREAM, PROTO_SDP);
#elif defined(__linux__)
/**
* IPv6 not supported by SDP on Linux
*/
if (ipv6_available()) {
JNU_ThrowIOException(env, "IPv6 not supported");
return -1;
}
s = socket(AF_INET_SDP, SOCK_STREAM, 0);
#else
/* not supported on other platforms at this time */
s = -1;
errno = EPROTONOSUPPORT;
#endif
if (s < 0)
JNU_ThrowIOExceptionWithLastError(env, "socket");
return s;
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:33,代码来源:SdpSupport.c
示例16: JNU_ThrowIOExceptionWithLastError
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: sendQuitTo
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_LinuxVirtualMachine_sendQuitTo
(JNIEnv *env, jclass cls, jint pid)
{
if (kill((pid_t)pid, SIGQUIT)) {
JNU_ThrowIOExceptionWithLastError(env, "kill");
}
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:12,代码来源:LinuxVirtualMachine.c
示例17: Java_java_lang_ProcessImpl_openForAtomicAppend
JNIEXPORT jlong JNICALL
Java_java_lang_ProcessImpl_openForAtomicAppend(JNIEnv *env, jclass ignored, jstring path)
{
const DWORD access = (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA);
const DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
const DWORD disposition = OPEN_ALWAYS;
const DWORD flagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
HANDLE h;
WCHAR *pathbuf = getPath(env, path);
if (pathbuf == NULL) {
/* Exception already pending */
return -1;
}
h = CreateFileW(
pathbuf, /* Wide char path name */
access, /* Read and/or write permission */
sharing, /* File sharing flags */
NULL, /* Security attributes */
disposition, /* creation disposition */
flagsAndAttributes, /* flags and attributes */
NULL);
free(pathbuf);
if (h == INVALID_HANDLE_VALUE) {
JNU_ThrowIOExceptionWithLastError(env, "CreateFileW");
}
return ptr_to_jlong(h);
}
开发者ID:lambdalab-mirror,项目名称:jdk7u-jdk,代码行数:27,代码来源:ProcessImpl_md.c
示例18: sizeof
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: write
* Signature: (I[B)V
*/
JNIEXPORT void JNICALL Java_sun_tools_attach_LinuxVirtualMachine_write
(JNIEnv *env, jclass cls, jint fd, jbyteArray ba, jint off, jint bufLen)
{
size_t remaining = bufLen;
do {
unsigned char buf[128];
size_t len = sizeof(buf);
int n;
if (len > remaining) {
len = remaining;
}
(*env)->GetByteArrayRegion(env, ba, off, len, (jbyte *)buf);
RESTARTABLE(write(fd, buf, len), n);
if (n > 0) {
off += n;
remaining -= n;
} else {
JNU_ThrowIOExceptionWithLastError(env, "write");
return;
}
} while (remaining > 0);
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:30,代码来源:LinuxVirtualMachine.c
示例19: jstring_to_cstring
/*
* Class: sun_tools_attach_WindowsVirtualMachine
* Method: createPipe
* Signature: (Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_sun_tools_attach_WindowsVirtualMachine_createPipe
(JNIEnv *env, jclass cls, jstring pipename)
{
HANDLE hPipe;
char name[MAX_PIPE_NAME_LENGTH];
jstring_to_cstring(env, pipename, name, MAX_PIPE_NAME_LENGTH);
hPipe = CreateNamedPipe(
name, // pipe name
PIPE_ACCESS_INBOUND, // read access
PIPE_TYPE_BYTE | // byte mode
PIPE_READMODE_BYTE |
PIPE_WAIT, // blocking mode
1, // max. instances
128, // output buffer size
8192, // input buffer size
NMPWAIT_USE_DEFAULT_WAIT, // client time-out
NULL); // default security attribute
if (hPipe == INVALID_HANDLE_VALUE) {
JNU_ThrowIOExceptionWithLastError(env, "CreateNamedPipe failed");
}
return (jlong)hPipe;
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:30,代码来源:WindowsVirtualMachine.c
示例20: JNU_ThrowIOExceptionWithLastError
/*
* Class: sun_nio_ch_sctp_SctpNet
* Method: preClose0
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_sun_nio_ch_sctp_SctpNet_preClose0
(JNIEnv *env, jclass clazz, jint fd) {
if (preCloseFD >= 0) {
if (dup2(preCloseFD, fd) < 0)
JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
}
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:13,代码来源:SctpNet.c
注:本文中的JNU_ThrowIOExceptionWithLastError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论