Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modifiers in right order
[simgrid.git] / src / bindings / java / org / simgrid / msg / File.java
1 /* Copyright (c) 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 package org.simgrid.msg;
8
9 public class File {
10         public static final int SEEK_SET = 0;
11         public static final int SEEK_CUR = 1;
12         public static final int SEEK_END = 2;
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 path is the file location on the storage 
22          */
23         public File(String path) {
24                 open(path);
25         }
26         @Override
27         protected void finalize() {
28
29         }
30         /**
31          * Opens the file whose name is the string pointed to by path.  
32          * @param path is the file location on the storage
33          */
34         protected native void open(String path);
35         /**
36          * Read elements of a file. 
37          * @param size of each element
38          * @param nMemb is the number of elements of data to write 
39          */
40         public native long read(long size, long nMemb);
41         /**
42          * Write elements into a file. 
43          * @param size of each element  
44          * @param nMemb is the number of elements of data to write 
45          */
46         public native long write(long size, long nMemb);
47         /**
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)
53          */
54         public native void seek(long offset, long origin);
55
56         /** Close the file. */
57         public native void close();
58
59         /** Class initializer, to initialize various JNI stuff */
60         public static native void nativeInit();
61         static {
62                 org.simgrid.NativeLib.nativeInit();
63                 nativeInit();
64         }       
65 }