1 package org.simgrid.msg;
3 * Copyright 2012 The SimGrid team. All right reserved.
5 * This program is free software; you can redistribute
6 * it and/or modify it under the terms of the license
7 * (GNU LGPL) which comes with this package.
12 protected String storage;
14 * Represents the bind between the java comm and the
15 * native C comm. You must never access it, since it is
20 * Constructor, opens the file.
21 * @param storage is the name where you can find the stream
22 * @param path is the file location on the storage
23 * @param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
25 public File(String storage, String path, String mode) {
26 this.storage = storage;
27 open(storage, path, mode);
29 protected void finalize() {
33 * Opens the file whose name is the string pointed to by path.
34 * @param storage is the name where you can find the stream
35 * @param path is the file location on the storage
36 * @param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
38 protected native void open(String storage, String path, String mode);
40 * Read elements of a file.
41 * @param storage is the name where you can find the stream
42 * @param size of each element
43 * @param nMemb is the number of elements of data to write
45 public native long read(String storage, long size, long nMemb);
47 * Write elements into a file.
48 * @param storage is the name where you can find the stream
49 * @param size of each element
50 * @param nMemb is the number of elements of data to write
52 public native long write(String storage, long size, long nMemb);
55 * @param storage is the name where you can find the stream
57 public native void close(String storage);
60 * Class initializer, to initialize various JNI stuff
62 public static native void nativeInit();