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
index 9076bcf..5263adb 100644 (file)
@@ -1,67 +1,65 @@
+/* Copyright (c) 2012-2020. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 package org.simgrid.msg;
-/**
-* Copyright 2012 The SimGrid team. All right reserved. 
-*
-* This program is free software; you can redistribute 
-* it and/or modify it under the terms of the license 
-* (GNU LGPL) which comes with this package.
-*
-*/
 
 public class File {
-       protected String storage;
+       public static final int SEEK_SET = 0;
+       public static final int SEEK_CUR = 1;
+       public static final int SEEK_END = 2;
        /**
         * Represents the bind between the java comm and the
-        * native C comm. You must never access it, since it is 
+        * native C comm. You must never access it, since it is
         * automatically set.
         */
        private long bind = 0;
        /**
         * Constructor, opens the file.
-        * @param storage is the name where you can find the stream 
-        * @param path is the file location on the storage 
-        * @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.
+        * @param path is the file location on the storage
         */
-       public File(String storage, String path, String mode) {
-               this.storage = storage;
-               open(storage, path, mode);
+       public File(String path) {
+               open(path);
        }
-       protected void finalize() {
 
-       }
        /**
-        * Opens the file whose name is the string pointed to by path. 
-        * @param storage is the name where you can find the stream 
+        * Opens the file whose name is the string pointed to by path.
         * @param path is the file location on the storage
-        * @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.
         */
-       protected native void open(String storage, String path, String mode);
+       protected native void open(String path);
        /**
-        * Read elements of a file. 
-        * @param storage is the name where you can find the stream
+        * Read elements of a file.
         * @param size of each element
-        * @param nMemb is the number of elements of data to write 
+        * @param nMemb is the number of elements of data to write
+        * @return the actually read size
         */
        public native long read(long size, long nMemb);
+
        /**
-        * Write elements into a file. 
-        * @param storage is the name where you can find the stream 
-        * @param size of each element  
-        * @param nMemb is the number of elements of data to write 
+        * Write elements into a file.
+        * @param size of each element
+        * @param nMemb is the number of elements of data to write
+        * @return the actually written size
         */
        public native long write(long size, long nMemb);
        /**
-        * Close the file.      
-        * @param storage is the name where you can find the stream 
-        */
+        * Write elements into a file.
+        * @param offset : number of bytes to offset from origin
+        * @param origin : Position used as reference for the offset. It is specified by one of the following constants
+        *                 defined in <stdio.h> exclusively to be used as arguments for this function (SEEK_SET =
+        *                 beginning of file, SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
+        */
+       public native void seek(long offset, long origin);
+
+       /** Close the file. */
        public native void close();
-       
-       /**
-        * Class initializer, to initialize various JNI stuff
-        */
+
+       /** Class initializer, to initialize various JNI stuff */
        public static native void nativeInit();
        static {
-               Msg.nativeInit();
+               org.simgrid.NativeLib.nativeInit();
                nativeInit();
        }       
 }
\ No newline at end of file