< prev index next >

src/java.base/unix/native/libjava/UnixFileSystem_md.c

Print this page
rev 17281 : 8181207: 8177809 breaks AIX 5.3, 6.1 builds
Reviewed-by:


 212                 mode |= amode;
 213             else
 214                 mode &= ~amode;
 215             if (chmod(path, mode) >= 0) {
 216                 rv = JNI_TRUE;
 217             }
 218         }
 219     } END_PLATFORM_STRING(env, path);
 220     return rv;
 221 }
 222 
 223 JNIEXPORT jlong JNICALL
 224 Java_java_io_UnixFileSystem_getLastModifiedTime(JNIEnv *env, jobject this,
 225                                                 jobject file)
 226 {
 227     jlong rv = 0;
 228 
 229     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 230         struct stat64 sb;
 231         if (stat64(path, &sb) == 0) {




 232 #ifndef MACOSX
 233             rv  = (jlong)sb.st_mtim.tv_sec * 1000;
 234             rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
 235 #else
 236             rv  = (jlong)sb.st_mtimespec.tv_sec * 1000;
 237             rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000;
 238 #endif

 239         }
 240     } END_PLATFORM_STRING(env, path);
 241     return rv;
 242 }
 243 
 244 
 245 JNIEXPORT jlong JNICALL
 246 Java_java_io_UnixFileSystem_getLength(JNIEnv *env, jobject this,
 247                                       jobject file)
 248 {
 249     jlong rv = 0;
 250 
 251     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 252         struct stat64 sb;
 253         if (stat64(path, &sb) == 0) {
 254             rv = sb.st_size;
 255         }
 256     } END_PLATFORM_STRING(env, path);
 257     return rv;
 258 }


 402                 rv = JNI_TRUE;
 403             }
 404         } END_PLATFORM_STRING(env, toPath);
 405     } END_PLATFORM_STRING(env, fromPath);
 406     return rv;
 407 }
 408 
 409 JNIEXPORT jboolean JNICALL
 410 Java_java_io_UnixFileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
 411                                                 jobject file, jlong time)
 412 {
 413     jboolean rv = JNI_FALSE;
 414 
 415     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 416         struct stat64 sb;
 417 
 418         if (stat64(path, &sb) == 0) {
 419             struct timeval tv[2];
 420 
 421             /* Preserve access time */




 422 #ifndef MACOSX
 423             tv[0].tv_sec = sb.st_atim.tv_sec;
 424             tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
 425 #else
 426             tv[0].tv_sec = sb.st_atimespec.tv_sec;
 427             tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
 428 #endif
 429 
 430             /* Change last-modified time */
 431             tv[1].tv_sec = time / 1000;
 432             tv[1].tv_usec = (time % 1000) * 1000;
 433 
 434             if (utimes(path, tv) == 0)
 435                 rv = JNI_TRUE;
 436         }
 437     } END_PLATFORM_STRING(env, path);
 438 
 439     return rv;
 440 }
 441 
 442 
 443 JNIEXPORT jboolean JNICALL
 444 Java_java_io_UnixFileSystem_setReadOnly(JNIEnv *env, jobject this,
 445                                         jobject file)
 446 {
 447     jboolean rv = JNI_FALSE;
 448 
 449     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {




 212                 mode |= amode;
 213             else
 214                 mode &= ~amode;
 215             if (chmod(path, mode) >= 0) {
 216                 rv = JNI_TRUE;
 217             }
 218         }
 219     } END_PLATFORM_STRING(env, path);
 220     return rv;
 221 }
 222 
 223 JNIEXPORT jlong JNICALL
 224 Java_java_io_UnixFileSystem_getLastModifiedTime(JNIEnv *env, jobject this,
 225                                                 jobject file)
 226 {
 227     jlong rv = 0;
 228 
 229     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 230         struct stat64 sb;
 231         if (stat64(path, &sb) == 0) {
 232 #ifdef _AIX
 233             /* AIX 5.3 backward compatibility. */
 234             rv = 1000 * (jlong)sb.st_mtime;
 235 #else
 236 #ifndef MACOSX
 237             rv  = (jlong)sb.st_mtim.tv_sec * 1000;
 238             rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
 239 #else
 240             rv  = (jlong)sb.st_mtimespec.tv_sec * 1000;
 241             rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000;
 242 #endif
 243 #endif
 244         }
 245     } END_PLATFORM_STRING(env, path);
 246     return rv;
 247 }
 248 
 249 
 250 JNIEXPORT jlong JNICALL
 251 Java_java_io_UnixFileSystem_getLength(JNIEnv *env, jobject this,
 252                                       jobject file)
 253 {
 254     jlong rv = 0;
 255 
 256     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 257         struct stat64 sb;
 258         if (stat64(path, &sb) == 0) {
 259             rv = sb.st_size;
 260         }
 261     } END_PLATFORM_STRING(env, path);
 262     return rv;
 263 }


 407                 rv = JNI_TRUE;
 408             }
 409         } END_PLATFORM_STRING(env, toPath);
 410     } END_PLATFORM_STRING(env, fromPath);
 411     return rv;
 412 }
 413 
 414 JNIEXPORT jboolean JNICALL
 415 Java_java_io_UnixFileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
 416                                                 jobject file, jlong time)
 417 {
 418     jboolean rv = JNI_FALSE;
 419 
 420     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
 421         struct stat64 sb;
 422 
 423         if (stat64(path, &sb) == 0) {
 424             struct timeval tv[2];
 425 
 426             /* Preserve access time */
 427 #ifdef _AIX
 428             tv[0].tv_sec = sb.st_atime;
 429             tv[0].tv_usec = 0;
 430 #else
 431 #ifndef MACOSX
 432             tv[0].tv_sec = sb.st_atim.tv_sec;
 433             tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
 434 #else
 435             tv[0].tv_sec = sb.st_atimespec.tv_sec;
 436             tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
 437 #endif
 438 #endif
 439             /* Change last-modified time */
 440             tv[1].tv_sec = time / 1000;
 441             tv[1].tv_usec = (time % 1000) * 1000;
 442 
 443             if (utimes(path, tv) == 0)
 444                 rv = JNI_TRUE;
 445         }
 446     } END_PLATFORM_STRING(env, path);
 447 
 448     return rv;
 449 }
 450 
 451 
 452 JNIEXPORT jboolean JNICALL
 453 Java_java_io_UnixFileSystem_setReadOnly(JNIEnv *env, jobject this,
 454                                         jobject file)
 455 {
 456     jboolean rv = JNI_FALSE;
 457 
 458     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {


< prev index next >