MCPcopy Create free account
hub / github.com/ReadyTalk/avian / Java_java_io_File_setExecutable

Function Java_java_io_File_setExecutable

classpath/java-io.cpp:444–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442
443#ifndef PLATFORM_WINDOWS
444extern "C" JNIEXPORT jboolean JNICALL
445 Java_java_io_File_setExecutable(JNIEnv* e,
446 jclass,
447 jstring path,
448 jboolean executable,
449 jboolean ownerOnly)
450{
451 string_t chars = getChars(e, path);
452 if (chars) {
453 jboolean v;
454 int mask;
455 if (ownerOnly) {
456 mask = S_IXUSR;
457 } else {
458 mask = S_IXUSR | S_IXGRP | S_IXOTH;
459 }
460
461 STRUCT_STAT s;
462 int r = STAT(chars, &s);
463 if (r == 0) {
464 int mode = s.st_mode;
465 if (executable) {
466 mode |= mask;
467 } else {
468 mode &= ~mask;
469 }
470 if (CHMOD(chars, mode) != 0) {
471 v = false;
472 } else {
473 v = true;
474 }
475 } else {
476 v = false;
477 }
478 releaseChars(e, path, chars);
479 return v;
480 }
481 return false;
482}
483
484#else // ifndef PLATFORM_WINDOWS
485

Callers

nothing calls this directly

Calls 3

getCharsFunction · 0.85
STATClass · 0.85
releaseCharsFunction · 0.85

Tested by

no test coverage detected