• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ JNU_ReleaseStringPlatformChars函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JNU_ReleaseStringPlatformChars函数的典型用法代码示例。如果您正苦于以下问题:C++ JNU_ReleaseStringPlatformChars函数的具体用法?C++ JNU_ReleaseStringPlatformChars怎么用?C++ JNU_ReleaseStringPlatformChars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JNU_ReleaseStringPlatformChars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: 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


示例2: Java_sun_print_Win32PrintService_getCopiesSupported

JNIEXPORT jint JNICALL
Java_sun_print_Win32PrintService_getCopiesSupported(JNIEnv *env,
                                                    jobject peer,
                                                    jstring printer,
                                                    jstring port)
{
  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  if (printerName == NULL || printerPort == NULL) {
      if (printerName != NULL) {
          JNU_ReleaseStringPlatformChars(env, printer, printerName);
      }
      if (printerPort != NULL) {
          JNU_ReleaseStringPlatformChars(env, port, printerPort);
      }
      return 1;
  }

  SAVE_CONTROLWORD
  int numCopies = ::DeviceCapabilities(printerName, printerPort,
                                       DC_COPIES,   NULL, NULL);
  RESTORE_CONTROLWORD

  if (numCopies == -1)
    return 1; // default

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);

  return numCopies;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:32,代码来源:WPrinterJob.cpp


示例3: Java_sun_print_Win32PrintService_getAllResolutions

/*
PostScript Drivers return wrong support info for the following code:

 DWORD dmFields = (::DeviceCapabilities(printerName,
                                         NULL, DC_FIELDS,   NULL, NULL)) ;

  if ((dmFields & DM_YRESOLUTION) )
    isSupported = true;

Returns not supported even if it supports resolution. Therefore, we use the
function _getAllResolutions.
*/
JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllResolutions(JNIEnv *env,
                                                   jobject peer,
                                                   jstring printer,
                                                   jstring port)
{
  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

 if (printerName == NULL || printerPort == NULL) {
      if (printerName != NULL) {
          JNU_ReleaseStringPlatformChars(env, printer, printerName);
      }
      if (printerPort != NULL) {
          JNU_ReleaseStringPlatformChars(env, port, printerPort);
      }
      return NULL;
  }

  SAVE_CONTROLWORD
  int nResolutions = ::DeviceCapabilities(printerName, printerPort,
                                          DC_ENUMRESOLUTIONS, NULL, NULL);
  RESTORE_CONTROLWORD

  jintArray resolutionArray = NULL;
  if (nResolutions > 0) {
    resolutionArray = env->NewIntArray(nResolutions*2);
    if (resolutionArray != NULL) {
        jint *jpcIndices = env->GetIntArrayElements(resolutionArray, NULL);
        if (jpcIndices != NULL) {
            jint *saveFormats = jpcIndices;
            LPTSTR resBuf = NULL;
            try {
                resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2];
            } catch (std::bad_alloc&) {
                resBuf = NULL;
            }
            if (resBuf != NULL) {
                if (::DeviceCapabilities(printerName, printerPort,
                                         DC_ENUMRESOLUTIONS, resBuf,
                                         NULL) != -1) {
                    LONG *pResolution = (LONG *)resBuf;
                    for (int i = 0; i < nResolutions; i++) {
                        jpcIndices[i*2] = *pResolution++;
                        jpcIndices[i*2+1] = *pResolution++;
                    }
                }
                RESTORE_CONTROLWORD
                delete[] resBuf;
            }
            env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0);
        }
    }
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, printer, printerPort);
  return resolutionArray;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:71,代码来源:WPrinterJob.cpp


示例4: getIDs

jintArray getIDs(JNIEnv *env, jstring printer, jstring port, int dm_id)
{

  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  if (printerName == NULL || printerPort == NULL) {
      if (printerName != NULL) {
          JNU_ReleaseStringPlatformChars(env, printer, printerName);
      }
      if (printerPort != NULL) {
          JNU_ReleaseStringPlatformChars(env, port, printerPort);
      }
      return NULL;
  }

  SAVE_CONTROLWORD
  int numIDs = ::DeviceCapabilities(printerName, printerPort, dm_id,
                                    NULL, NULL);
  RESTORE_CONTROLWORD

  jintArray idArray = NULL;
  if (numIDs > 0) {
      idArray = env->NewIntArray(numIDs);
      if (idArray != NULL) {
          jint *jpcIndices = env->GetIntArrayElements(idArray, NULL);
          if (jpcIndices != NULL) {
              jint *saveFormats = jpcIndices;
              LPTSTR buf = NULL;
              try {
                  buf = (LPTSTR)new char[numIDs * sizeof(WORD)];
              } catch (std::bad_alloc&) {
                  buf = NULL;
              }
              if (buf != NULL) {
                  if (::DeviceCapabilities(printerName, printerPort,
                                           dm_id, buf, NULL) != -1) {
                      WORD *id = (WORD *)buf;
                      for (int i = 0; i < numIDs; i++, id++) {
                          jpcIndices[i] = *id;
                      }
                  }
                  RESTORE_CONTROLWORD
                  delete[] buf;
              }
              env->ReleaseIntArrayElements(idArray, saveFormats, 0);
          }
      }
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);
  return idArray;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:54,代码来源:WPrinterJob.cpp


示例5: Java_sun_print_Win32PrintService_getAllMediaSizes

JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaSizes(JNIEnv *env,
                                                  jobject peer,
                                                  jstring printer,
                                                  jstring port)
{
  TRY;

  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                          printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  jintArray mediaArray = NULL;

  SAVE_CONTROLWORD
  int nPapers = ::DeviceCapabilities(printerName, printerPort,
                                      DC_PAPERSIZE,   NULL, NULL) ;
  RESTORE_CONTROLWORD
  if (nPapers > 0) {
    mediaArray = env->NewIntArray(nPapers*2);
    if (mediaArray == NULL) {
      throw std::bad_alloc();
    }

    jboolean isCopy;
    jint *jpcIndices = env->GetIntArrayElements(mediaArray,
                                          &isCopy), *saveFormats = jpcIndices;

    LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs

    if (::DeviceCapabilities(printerName, printerPort,
                             DC_PAPERSIZE, buf, NULL) != -1) {

      POINT *pDim = (POINT *)buf;
      for (int i = 0; i < nPapers; i++) {
        jpcIndices[i*2] = (pDim+i)->x;
        jpcIndices[i*2+1] = (pDim+i)->y;
      }
    }
    RESTORE_CONTROLWORD
    delete[] buf;
    env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);
  return mediaArray;

  CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:50,代码来源:WPrinterJob.cpp


示例6: Java_sun_print_Win32PrintService_getAllMediaTrays

JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaTrays(JNIEnv *env,
                                                  jobject peer,
                                                  jstring printer,
                                                  jstring port)
{
  TRY;

  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                          printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  jintArray mediaTrayArray = NULL;

  SAVE_CONTROLWORD
  int nBins = ::DeviceCapabilities(printerName, printerPort,
                                   DC_BINS,   NULL, NULL) ;
  RESTORE_CONTROLWORD
  if (nBins > 0) {
    mediaTrayArray = env->NewIntArray(nBins);
    if (mediaTrayArray == NULL) {
      throw std::bad_alloc();
    }

    jboolean isCopy;
    jint *jpcIndices = env->GetIntArrayElements(mediaTrayArray,
                                           &isCopy), *saveFormats = jpcIndices;

    LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)];

    if (::DeviceCapabilities(printerName, printerPort,
                             DC_BINS, buf, NULL) != -1) {
      RESTORE_CONTROLWORD
      WORD *pBins = (WORD *)buf;
      for (int i = 0; i < nBins; i++) {
        jpcIndices[i] = *(pBins+i);
      }
    }
    delete[] buf;
    env->ReleaseIntArrayElements(mediaTrayArray, saveFormats, 0);
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);
  return mediaTrayArray;

  CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:48,代码来源:WPrinterJob.cpp


示例7: GetStringPlatformChars

/*
 * Class:     sun_tools_attach_VirtualMachineImpl
 * Method:    open
 * Signature: (Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
  (JNIEnv *env, jclass cls, jstring path)
{
    jboolean isCopy;
    const char* p = GetStringPlatformChars(env, path, &isCopy);
    if (p == NULL) {
        return 0;
    } else {
        int fd;
        int err = 0;

        fd = open(p, O_RDWR);
        if (fd == -1) {
            err = errno;
        }

        if (isCopy) {
            JNU_ReleaseStringPlatformChars(env, path, p);
        }

        if (fd == -1) {
            if (err == ENOENT) {
                JNU_ThrowByName(env, "java/io/FileNotFoundException", NULL);
            } else {
                char* msg = strdup(strerror(err));
                JNU_ThrowIOException(env, msg);
                if (msg != NULL) {
                    free(msg);
                }
            }
        }
        return fd;
    }
}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:39,代码来源:VirtualMachineImpl.c


示例8: JNI_CHECK_PEER_GOTO

void AwtList::_AddItems(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    AddItemsStruct *ais = (AddItemsStruct *)param;
    jobject self = ais->list;
    jobjectArray items = ais->items;
    jint index = ais->index;
    jint width = ais->width;

    int badAlloc = 0;
    AwtList *l = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(self, ret);
    JNI_CHECK_NULL_GOTO(items, "null items", ret);
    l = (AwtList*)pData;
    if (::IsWindow(l->GetHWnd()))
    {
        int itemCount = env->GetArrayLength(items);
        if (itemCount > 0)
        {
            AwtList* l = (AwtList*)pData;
            l->SendListMessage(WM_SETREDRAW, (WPARAM)FALSE, 0);
            for (jsize i=0; i < itemCount; i++)
            {
                LPTSTR itemPtr = NULL;
                jstring item = (jstring)env->GetObjectArrayElement(items, i);
                if (env->ExceptionCheck()) goto ret;
                if (item == NULL) goto next_item;
                itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);
                if (itemPtr == NULL)
                {
                    badAlloc = 1;
                }
                else
                {
                    l->InsertString(index+i, itemPtr);
                    JNU_ReleaseStringPlatformChars(env, item, itemPtr);
                }
                env->DeleteLocalRef(item);
next_item:
                ;
            }
            l->SendListMessage(WM_SETREDRAW, (WPARAM)TRUE, 0);
            l->InvalidateList(NULL, TRUE);
            l->CheckMaxWidth(width);
        }
    }
ret:
    env->DeleteGlobalRef(self);
    env->DeleteGlobalRef(items);

    delete ais;

    if (badAlloc)
    {
        throw std::bad_alloc();
    }
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:60,代码来源:awt_List.cpp


示例9: GetMenuContainer

void AwtPopupMenu::Enable(BOOL isEnabled)
{
    AwtMenu *menu = GetMenuContainer();
    if (menu != NULL) {
        AwtMenu::Enable(isEnabled);
        return;
    }
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(1) < 0) {
        return;
    }
    jobject target = GetTarget(env);
    int nCount = CountItem(target);
    for (int i = 0; i < nCount; ++i) {
        AwtMenuItem *item = GetItem(target,i);
        jobject jitem = item->GetTarget(env);
        BOOL bItemEnabled = isEnabled && (jboolean)env->GetBooleanField(jitem,
            AwtMenuItem::enabledID);
        jstring labelStr = static_cast<jstring>(env->GetObjectField(jitem, AwtMenuItem::labelID));
        LPCWSTR labelStrW = JNU_GetStringPlatformChars(env, labelStr, NULL);
        if (labelStrW  && wcscmp(labelStrW, L"-") != 0) {
            item->Enable(bItemEnabled);
        }
        JNU_ReleaseStringPlatformChars(env, labelStr, labelStrW);
        env->DeleteLocalRef(labelStr);
        env->DeleteLocalRef(jitem);
    }
    env->DeleteLocalRef(target);
}
开发者ID:txazo,项目名称:hotspot,代码行数:29,代码来源:awt_PopupMenu.cpp


示例10: Java_sun_print_Win32PrintServiceLookup_notifyFirstPrinterChange

JNIEXPORT jlong JNICALL
Java_sun_print_Win32PrintServiceLookup_notifyFirstPrinterChange(JNIEnv *env,
                                                                jobject peer,
                                                                jstring printer) {
    HANDLE hPrinter;

    LPTSTR printerName = NULL;
    if (printer != NULL) {
        printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                         printer,
                                                         NULL);
        JNU_ReleaseStringPlatformChars(env, printer, printerName);
    }

    // printerName - "Win NT/2K/XP: If NULL, it indicates the local printer
    // server" - MSDN.   Win9x : OpenPrinter returns 0.
    BOOL ret = OpenPrinter(printerName, &hPrinter, NULL);
    if (!ret) {
      return (jlong)-1;
    }

    // PRINTER_CHANGE_PRINTER = PRINTER_CHANGE_ADD_PRINTER |
    //                          PRINTER_CHANGE_SET_PRINTER |
    //                          PRINTER_CHANGE_DELETE_PRINTER |
    //                          PRINTER_CHANGE_FAILED_CONNECTION_PRINTER
    HANDLE chgObj = FindFirstPrinterChangeNotification(hPrinter,
                                                       PRINTER_CHANGE_PRINTER,
                                                       0,
                                                       NULL);
    return (chgObj == INVALID_HANDLE_VALUE) ? (jlong)-1 : (jlong)chgObj;
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:31,代码来源:WPrinterJob.cpp


示例11: 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


示例12: GetStringPlatformChars

/*
 * Class:     sun_tools_attach_VirtualMachineImpl
 * Method:    checkPermissions
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
  (JNIEnv *env, jclass cls, jstring path)
{
    jboolean isCopy;
    const char* p = GetStringPlatformChars(env, path, &isCopy);
    if (p != NULL) {
        struct stat64 sb;
        uid_t uid, gid;
        int res;

        /*
         * Check that the path is owned by the effective uid/gid of this
         * process. Also check that group/other access is not allowed.
         */
        uid = geteuid();
        gid = getegid();

        res = stat64(p, &sb);
        if (res != 0) {
            /* save errno */
            res = errno;
        }

        if (res == 0) {
            char msg[100];
            jboolean isError = JNI_FALSE;
            if (sb.st_uid != uid) {
                jio_snprintf(msg, sizeof(msg)-1,
                    "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
                isError = JNI_TRUE;
            } else if (sb.st_gid != gid) {
                jio_snprintf(msg, sizeof(msg)-1,
                    "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
                isError = JNI_TRUE;
            } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
                jio_snprintf(msg, sizeof(msg)-1,
                    "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
                isError = JNI_TRUE;
            }
            if (isError) {
                char buf[256];
                jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
                JNU_ThrowIOException(env, buf);
            }
        } else {
            char* msg = strdup(strerror(res));
            JNU_ThrowIOException(env, msg);
            if (msg != NULL) {
                free(msg);
            }
        }

        if (isCopy) {
            JNU_ReleaseStringPlatformChars(env, path, p);
        }
    }
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:62,代码来源:VirtualMachineImpl.c


示例13: JNI_CHECK_PEER_GOTO

void AwtCheckbox::_SetLabel(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    SetLabelStruct *sls = (SetLabelStruct *)param;
    jobject checkbox = sls->checkbox;
    jstring label = sls->label;

    int badAlloc = 0;
    AwtCheckbox *c = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(checkbox, done);

    c = (AwtCheckbox *)pData;
    if (::IsWindow(c->GetHWnd()))
    {
        LPCTSTR labelStr = NULL;

        // By convension null label means empty string
        if (label == NULL)
        {
            labelStr = TEXT("");
        }
        else
        {
            labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE);
        }

        if (labelStr == NULL)
        {
            badAlloc = 1;
        }
        else
        {
            c->SetText(labelStr);
            c->VerifyState();
            if (label != NULL) {
                JNU_ReleaseStringPlatformChars(env, label, labelStr);
            }
        }
    }

done:
    env->DeleteGlobalRef(checkbox);
    if (label != NULL)
    {
        env->DeleteGlobalRef(label);
    }

    delete sls;

    if (badAlloc) {
        throw std::bad_alloc();
    }
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:56,代码来源:awt_Checkbox.cpp


示例14: Java_sun_awt_DebugHelperImpl_printlnImpl

/* Implementation of DebugHelperImpl.printlnImpl */
JNIEXPORT void JNICALL
Java_sun_awt_DebugHelperImpl_printlnImpl(JNIEnv *env, jclass cls, jstring msg) {
    const char *	cstr;
    cstr = JNU_GetStringPlatformChars(env, msg, NULL);
    if ( cstr == NULL ) {
	return;
    }
    DTrace_JavaPrintln(cstr);
    JNU_ReleaseStringPlatformChars(env, msg, cstr);
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:11,代码来源:debug_trace.c


示例15: Java_java_util_prefs_FileSystemPreferences_chmod

JNIEXPORT jint JNICALL
Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
        jclass thisclass, jstring java_fname, jint permission) {
    const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE);
    int result;
    result =  chmod(fname, permission);
    if (result != 0)
        result = errno;
    JNU_ReleaseStringPlatformChars(env, java_fname, fname);
    return (jint) result;
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:11,代码来源:FileSystemPreferences.c


示例16: Java_java_util_prefs_FileSystemPreferences_lockFile0

/**
 * Try to open a named lock file.
 * The result is a cookie that can be used later to unlock the file.
 * On failure the result is zero.
 */
JNIEXPORT jintArray JNICALL
Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
    jclass thisclass, jstring java_fname, jint permission, jboolean shared) {
    const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
    int fd, rc;
    int result[2];
    jintArray javaResult = NULL;
    int old_umask;
    FLOCK fl;

    if (!fname)
        return javaResult;

    fl.l_whence = SEEK_SET;
    fl.l_len = 0;
    fl.l_start = 0;
    if (shared == JNI_TRUE) {
        fl.l_type = F_RDLCK;
    } else {
        fl.l_type = F_WRLCK;
    }

    if (shared == JNI_TRUE) {
        fd = open(fname, O_RDONLY, 0);
    } else {
        old_umask = umask(0);
        fd = open(fname, O_WRONLY|O_CREAT, permission);
        result[1] = errno;
        umask(old_umask);
    }

    if (fd < 0) {
        result[0] = 0;
    } else {
#if defined(_ALLBSD_SOURCE)
        rc = fcntl(fd, F_SETLK, &fl);
#else
        rc = fcntl(fd, F_SETLK64, &fl);
#endif
        result[1] = errno;
        if (rc < 0) {
            result[0]= 0;
            close(fd);
        } else {
          result[0] = fd;
        }
    }
    JNU_ReleaseStringPlatformChars(env, java_fname, fname);
    javaResult = (*env)->NewIntArray(env,2);
    if (javaResult)
        (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
    return javaResult;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:58,代码来源:FileSystemPreferences.c


示例17: Java_sun_awt_motif_MRobotPeer_buildChildProcessName

/*
 * Given the JDK/JRE install directory form the name of the robot child process
 * e.g. Directory /foo/kestrel/jre -> Executable /foo/kestrel/jre/bin/awt_robot
 */
JNIEXPORT void JNICALL Java_sun_awt_motif_MRobotPeer_buildChildProcessName(
    JNIEnv *env, jclass cls, jstring installDir) {
    char * cdir;	

    cdir = (char *) JNU_GetStringPlatformChars(env, installDir, NULL);
    if (cdir == NULL) {
	return;
    }
    sprintf(RobotChildExePath, "%s/%s", cdir, ROBOT_EXE);
    DTRACE_PRINTLN1("Robot child process name is : %s", RobotChildExePath);
    JNU_ReleaseStringPlatformChars(env, installDir, cdir);
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:16,代码来源:awt_Robot.c


示例18: JNU_GetStringPlatformChars

/*
 * Class:     sun_awt_windows_ThemeReader
 * Method:    setWindowTheme
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_setWindowTheme
(JNIEnv *env, jclass klass, jstring subAppName) {

    LPCTSTR str = NULL;
    if (subAppName != NULL) {
        str = (LPCTSTR) JNU_GetStringPlatformChars(env, subAppName, NULL);
    }
    // We need to set the Window theme on the same theme that we opened it with.
    HRESULT hres = SetWindowTheme(AwtToolkit::GetInstance().GetHWnd(), str, NULL);
    assert_result(hres, env);
    if (subAppName != NULL) {
        JNU_ReleaseStringPlatformChars(env, subAppName, str);
    }
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:19,代码来源:ThemeReader.cpp


示例19: Java_java_util_zip_ZipFile_open

JNIEXPORT jlong JNICALL
Java_java_util_zip_ZipFile_open(JNIEnv *env, jclass cls, jstring name,
                                        jint mode, jlong lastModified,
                                        jboolean usemmap)
{
    const char *path = JNU_GetStringPlatformChars(env, name, 0);
    char *msg = 0;
    jlong result = 0;
    int flag = 0;
    jzfile *zip = 0;

    if (mode & OPEN_READ) flag |= O_RDONLY;
    if (mode & OPEN_DELETE) flag |= JVM_O_DELETE;

    if (path != 0) {
        zip = ZIP_Get_From_Cache(path, &msg, lastModified);
        if (zip == 0 && msg == 0) {
            ZFILE zfd = 0;
#ifdef WIN32
            zfd = winFileHandleOpen(env, name, flag);
            if (zfd == -1) {
                /* Exception already pending. */
                goto finally;
            }
#else
            zfd = JVM_Open(path, flag, 0);
            if (zfd < 0) {
                throwFileNotFoundException(env, name);
                goto finally;
            }
#endif
            zip = ZIP_Put_In_Cache0(path, zfd, &msg, lastModified, usemmap);
        }

        if (zip != 0) {
            result = ptr_to_jlong(zip);
        } else if (msg != 0) {
            ThrowZipException(env, msg);
            free(msg);
        } else if (errno == ENOMEM) {
            JNU_ThrowOutOfMemoryError(env, 0);
        } else {
            ThrowZipException(env, "error in opening zip file");
        }
finally:
        JNU_ReleaseStringPlatformChars(env, name, path);
    }
    return result;
}
开发者ID:digideskio,项目名称:openjdk-fontfix,代码行数:49,代码来源:ZipFile.c


示例20: Java_sun_awt_windows_WDataTransferer_registerClipboardFormat

/*
 * Class:     sun_awt_windows_WDataTransferer
 * Method:    registerClipboardFormat
 * Signature: (Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL
Java_sun_awt_windows_WDataTransferer_registerClipboardFormat(JNIEnv *env,
                                                             jclass cls,
                                                             jstring str)
{
    TRY;

    LPCTSTR cStr = JNU_GetStringPlatformChars(env, str, NULL);
    jlong value = ::RegisterClipboardFormat(cStr);
    JNU_ReleaseStringPlatformChars(env, str, cStr);

    return value;

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:20,代码来源:awt_DataTransferer.cpp



注:本文中的JNU_ReleaseStringPlatformChars函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JNU_ThrowByName函数代码示例发布时间:2022-05-30
下一篇:
C++ JNU_GetEnv函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap