Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / bindings / java / jmsg_file.cpp
index 5b203d9..df60e71 100644 (file)
@@ -1,15 +1,13 @@
-/* Functions related to the java file API.                            */
+/* Java bindings of the file API.                                           */
 
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2021. 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. */
 
 #include "jmsg_file.h"
-#include "jxbt_utilities.h"
-
-SG_BEGIN_DECL()
+#include "jxbt_utilities.hpp"
+#include <xbt/asserts.h>
 
 void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t fd) {
   env->SetLongField(jfile, jfile_field_bind, reinterpret_cast<std::intptr_t>(fd));
@@ -26,33 +24,31 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jpath) {
-  const char *path = env->GetStringUTFChars((jstring) jpath, 0);
-  msg_file_t file  = MSG_file_open(path, nullptr);
+  const char* path = env->GetStringUTFChars((jstring)jpath, nullptr);
+  sg_file_t file   = sg_file_open(path, nullptr);
   jfile_bind(env, jfile, file);
 
   env->ReleaseStringUTFChars(static_cast<jstring>(jpath), path);
 }
 
 JNIEXPORT jlong JNICALL Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize) {
-  msg_file_t file = jfile_get_native(env, jfile);
-  return static_cast<jlong>(MSG_file_read(file, static_cast<sg_size_t>(jsize)));
+  sg_file_t file = jfile_get_native(env, jfile);
+  return static_cast<jlong>(sg_file_read(file, static_cast<sg_size_t>(jsize)));
 }
 
 JNIEXPORT jlong JNICALL Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jlong jsize) {
-  msg_file_t file = jfile_get_native(env, jfile);
-  return static_cast<jlong>(MSG_file_write(file, static_cast<sg_size_t>(jsize)));
+  sg_file_t file = jfile_get_native(env, jfile);
+  return static_cast<jlong>(sg_file_write(file, static_cast<sg_size_t>(jsize)));
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_File_seek(JNIEnv *env, jobject jfile, jlong offset, jlong origin) {
-  msg_file_t file = jfile_get_native(env, jfile);
-  MSG_file_seek(file, static_cast<sg_offset_t>(offset), static_cast<int>(origin));
+  sg_file_t file = jfile_get_native(env, jfile);
+  sg_file_seek(file, static_cast<sg_offset_t>(offset), static_cast<int>(origin));
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile) {
-  msg_file_t file = jfile_get_native(env, jfile);
+  const_sg_file_t file = jfile_get_native(env, jfile);
 
-  MSG_file_close(file);
+  sg_file_close(file);
   jfile_bind(env, jfile, nullptr);
 }
-
-SG_END_DECL()