1 /* Copyright (c) 2012-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 package org.simgrid.msg;
10 public static final int SEEK_SET = 0;
11 public static final int SEEK_CUR = 1;
12 public static final int SEEK_END = 2;
14 * Represents the bind between the java comm and the
15 * native C comm. You must never access it, since it is
18 private long bind = 0;
20 * Constructor, opens the file.
21 * @param path is the file location on the storage
23 public File(String path) {
27 protected void finalize() {
31 * Opens the file whose name is the string pointed to by path.
32 * @param path is the file location on the storage
34 protected native void open(String path);
36 * Read elements of a file.
37 * @param size of each element
38 * @param nMemb is the number of elements of data to write
40 public native long read(long size, long nMemb);
42 * Write elements into a file.
43 * @param size of each element
44 * @param nMemb is the number of elements of data to write
46 public native long write(long size, long nMemb);
48 * Write elements into a file.
49 * @param offset : number of bytes to offset from origin
50 * @param origin : Position used as reference for the offset. It is specified by one of the following constants
51 * defined in <stdio.h> exclusively to be used as arguments for this function (SEEK_SET =
52 * beginning of file, SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
54 public native void seek(long offset, long origin);
56 /** Close the file. */
57 public native void close();
59 /** Class initializer, to initialize various JNI stuff */
60 public static native void nativeInit();
62 org.simgrid.NativeLib.nativeInit();