/[classpath]/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
ViewVC logotype

Diff of /classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by rsdio, Sun Jul 10 20:11:33 2005 UTC revision 1.18 by mark, Mon Jul 11 17:27:55 2005 UTC
# Line 543  Java_gnu_java_nio_channels_FileChannelIm Line 543  Java_gnu_java_nio_channels_FileChannelIm
543            return (-1);            return (-1);
544          }          }
545      }      }
546    while (bytes_read != 1);    while (result != TARGET_NATIVE_OK);
547    
548    return ((jint) (data & 0xFF));    return ((jint) (data & 0xFF));
549  }  }
# Line 571  Java_gnu_java_nio_channels_FileChannelIm Line 571  Java_gnu_java_nio_channels_FileChannelIm
571    if (length == 0)    if (length == 0)
572      return 0;      return 0;
573    
574      if (offset < 0)
575        {
576          JCL_ThrowException (env, IO_EXCEPTION, "negative offset");
577          return -1;
578        }
579    
580    bufptr = (*env)->GetByteArrayElements (env, buffer, 0);    bufptr = (*env)->GetByteArrayElements (env, buffer, 0);
581    if (!bufptr)    if (!bufptr)
582      {      {
# Line 578  Java_gnu_java_nio_channels_FileChannelIm Line 584  Java_gnu_java_nio_channels_FileChannelIm
584        return (-1);        return (-1);
585      }      }
586    
587      if (length + offset > (*env)->GetArrayLength (env, buffer))
588        {
589          JCL_ThrowException (env, IO_EXCEPTION,
590                              "length + offset > buffer.length");
591          return -1;
592        }
593    
594    bytes_read = 0;    bytes_read = 0;
595    do    do
596      {      {
# Line 600  Java_gnu_java_nio_channels_FileChannelIm Line 613  Java_gnu_java_nio_channels_FileChannelIm
613            (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);            (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);
614            return -1;            return -1;
615          }          }
616        bytes_read += n;        if (result == TARGET_NATIVE_OK)
617            bytes_read += n;
618      }      }
619    while (bytes_read < 1);    while (bytes_read < 1);
620    
# Line 634  Java_gnu_java_nio_channels_FileChannelIm Line 648  Java_gnu_java_nio_channels_FileChannelIm
648          {          {
649            JCL_ThrowException (env, IO_EXCEPTION,            JCL_ThrowException (env, IO_EXCEPTION,
650                                TARGET_NATIVE_LAST_ERROR_STRING ());                                TARGET_NATIVE_LAST_ERROR_STRING ());
651              return;
652          }          }
653      }      }
654    while (result != TARGET_NATIVE_OK);    while (result != TARGET_NATIVE_OK);
655  }  }
656    
657  /*  /*
658     * Copies all parts of a file to disk.
659     */
660    JNIEXPORT void JNICALL
661    Java_gnu_java_nio_channels_FileChannelImpl_force (JNIEnv * env,
662                                                      jobject obj)
663    {
664      int native_fd;
665      int result;
666      native_fd = get_native_fd (env, obj);
667      TARGET_NATIVE_FILE_FSYNC (native_fd, result);
668      if (result != TARGET_NATIVE_OK)
669        JCL_ThrowException (env, IO_EXCEPTION,
670                            TARGET_NATIVE_LAST_ERROR_STRING ());
671    }
672    
673    /*
674   * Writes a byte buffer to the specified file descriptor   * Writes a byte buffer to the specified file descriptor
675   * Return status code, exception on error   * Return status code, exception on error
676   */   */
# Line 683  Java_gnu_java_nio_channels_FileChannelIm Line 714  Java_gnu_java_nio_channels_FileChannelIm
714            (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);            (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);
715            return;            return;
716          }          }
717        bytes_written += n;        if (result == TARGET_NATIVE_OK)
718            bytes_written += n;
719      }      }
720    
721    (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);    (*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0);

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26