Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / src / bindings / java / org / simgrid / msg / File.java
1 /* Copyright (c) 2012-2019. 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
27         /**
28          * Opens the file whose name is the string pointed to by path.
29          * @param path is the file location on the storage
30          */
31         protected native void open(String path);
32         /**
33          * Read elements of a file.
34          * @param size of each element
35          * @param nMemb is the number of elements of data to write
36          * @return the actually read size
37          */
38         public native long read(long size, long nMemb);
39
40         /**
41          * Write elements into a file.
42          * @param size of each element
43          * @param nMemb is the number of elements of data to write
44          * @return the actually written size
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 }