anyway.
size_t read,write;
if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
- file = MSG_file_open(mount,FILENAME1,"rw");
+ file = MSG_file_open(mount,FILENAME1);
else if(!strcmp(MSG_process_get_name(MSG_process_self()),"1"))
- file = MSG_file_open(mount,FILENAME2,"rw");
+ file = MSG_file_open(mount,FILENAME2);
else if(!strcmp(MSG_process_get_name(MSG_process_self()),"2"))
- file = MSG_file_open(mount,FILENAME3,"rw");
+ file = MSG_file_open(mount,FILENAME3);
else if(!strcmp(MSG_process_get_name(MSG_process_self()),"3"))
- file = MSG_file_open(mount,FILENAME4,"rw");
+ file = MSG_file_open(mount,FILENAME4);
else xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
XBT_INFO("\tOpen file '%s'",file->name);
// First open
XBT_INFO("\tOpen file '%s'",FILENAME1);
- file = MSG_file_open(mount,FILENAME1,"rw");
+ file = MSG_file_open(mount,FILENAME1);
// Unlink the file
XBT_INFO("\tUnlink file '%s'",file->name);
// Re Open the file wich is in fact created
XBT_INFO("\tOpen file '%s'",FILENAME1);
- file = MSG_file_open(mount,FILENAME1,"rw");
+ file = MSG_file_open(mount,FILENAME1);
// Write into the new file
write = MSG_file_write(ptr,100000,sizeof(char*),file); // Write for 100Ko
/************************** File handling ***********************************/
XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
-XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path, const char* mode);
+XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path);
XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd);
XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
- double max_duration);
+ double max_duration);
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
-XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb,
+ smx_file_t stream);
+XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
+ size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
}
JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath, jobject jmode) {
+Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath) {
const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
- const char *mode = (*env)->GetStringUTFChars(env, jmode, 0);
msg_file_t file;
- file = MSG_file_open(storage, path, mode);
+ file = MSG_file_open(storage, path);
jfile_bind(env, jfile, file);
(*env)->ReleaseStringUTFChars(env, jstorage, storage);
(*env)->ReleaseStringUTFChars(env, jpath, path);
- (*env)->ReleaseStringUTFChars(env, jmode, mode);
}
JNIEXPORT jlong JNICALL
Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
*/
typedef struct surf_storage_model_extension_public {
- surf_action_t(*open) (void *storage, const char* mount, const char* path, const char* mode);
+ surf_action_t(*open) (void *storage, const char* mount, const char* path);
surf_action_t(*close) (void *storage, surf_file_t fd);
surf_action_t(*read) (void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream);
surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
double rate);
double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
- surf_action_t(*open) (void *workstation, const char* storage, const char* path, const char* mode);
+ surf_action_t(*open) (void *workstation, const char* storage, const char* path);
surf_action_t(*close) (void *workstation, surf_file_t fd);
surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
-/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2004 - 2013. 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. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "msg_private.h"
#include "xbt/log.h"
*
* \param mount is the mount point where find the file is located
* \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.
*
* \return An #msg_file_t associated to the file
*/
-msg_file_t MSG_file_open(const char* mount, const char* path, const char* mode)
+msg_file_t MSG_file_open(const char* mount, const char* path)
{
msg_file_t file = xbt_new(s_msg_file_t,1);
file->name = strdup(path);
file->simdata = xbt_new0(s_simdata_file_t,1);
- file->simdata->smx_file = simcall_file_open(mount, path, mode);
+ file->simdata->smx_file = simcall_file_open(mount, path);
return file;
}
//SIMIX FILE OPEN
void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
- const char* path, const char* mode)
+ const char* path)
{
- smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path, mode);
+ smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const char* path, const char* mode)
+smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount,
+ const char* path)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.open(host, mount, path, mode);
+ action->io.surf_io =
+ surf_workstation_model->extension.workstation.open(host, mount, path);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
size_t nmemb, smx_file_t strea);
void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
- const char* path, const char* mode);
+ const char* path);
void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
void SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
void SIMIX_pre_file_ls(smx_simcall_t simcall,
const char* mount, const char* path);
size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path, const char* mode);
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+ size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
+ size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_open(smx_process_t process, const char* storage,
+ const char* path);
smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd);
smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
-smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount, const char *path);
+smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount,
+ const char *path);
size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
void SIMIX_post_io(smx_action_t action);
ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
-ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path), TSTRING(mode)) sep \
+ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path)) sep \
ACTION(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
ACTION(SIMCALL_FILE_LS, file_ls, WITHOUT_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(mount), TSTRING(path)) sep \
* \ingroup simix_file_management
* \brief
*/
-smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
+smx_file_t simcall_file_open(const char* mount, const char* path)
{
- return simcall_BODY_file_open(mount, path, mode);
+ return simcall_BODY_file_open(mount, path);
}
/**
return action;
}
-static surf_action_t storage_action_open(void *storage, const char* mount, const char* path, const char* mode)
+static surf_action_t storage_action_open(void *storage, const char* mount,
+ const char* path)
{
XBT_DEBUG("\tOpen file '%s'",path);
xbt_dict_t content_dict = ((storage_t)storage)->content;
return st;
}
-static surf_action_t ws_action_open(void *workstation, const char* mount, const char* path, const char* mode)
+static surf_action_t ws_action_open(void *workstation, const char* mount,
+ const char* path)
{
storage_t st = find_storage_on_mount_list(workstation, mount);
XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
- return model->extension.storage.open(st, mount, path, mode);
+ return model->extension.storage.open(st, mount, path);
}
static surf_action_t ws_action_close(void *workstation, surf_file_t fd)