Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the masterslave example
[simgrid.git] / org / simgrid / msg / File.java
1 package org.simgrid.msg;
2 /**
3 * Copyright 2012 The SimGrid team. All right reserved. 
4 *
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.
8 *
9 */
10
11 public class File {
12         protected String storage;
13         /**
14          * Represents the bind between the java comm and the
15          * native C comm. You must never access it, since it is 
16          * automatically set.
17          */
18         private long bind = 0;
19         /**
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.
24          */
25         public File(String storage, String path, String mode) {
26                 this.storage = storage;
27                 open(storage, path, mode);
28         }
29         protected void finalize() {
30
31         }
32         /**
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.
37          */
38         protected native void open(String storage, String path, String mode);
39         /**
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 
44          */
45         public native long read(long size, long nMemb);
46         /**
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 
51          */
52         public native long write(long size, long nMemb);
53         /**
54          * Close the file.      
55          * @param storage is the name where you can find the stream 
56          */
57         public native void close();
58         
59         /**
60          * Class initializer, to initialize various JNI stuff
61          */
62         public static native void nativeInit();
63         static {
64                 nativeInit();
65         }       
66 }