SIONlib  1.7.1
Scalable I/O library for parallel access to task-local files
sion_file.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2016 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
14 #ifndef SION_SION_FILE_H
15 #define SION_SION_FILE_H
16 
17 #include "sion.h"
18 
19 #define SION_FILE_FLAG_ANSI 1
20 #define SION_FILE_FLAG_SCNDANSI 2
21 #define SION_FILE_FLAG_POSIX 4
22 #define SION_FILE_FLAG_CREATE 8
23 #define SION_FILE_FLAG_WRITE 16
24 #define SION_FILE_FLAG_READ 32
26 struct _sion_fileptr_s {
27  unsigned int flags;
28  FILE *fileptr;
29  FILE *second_fileptr;
30  int fd;
31 };
32 typedef struct _sion_fileptr_s _sion_fileptr;
33 
34 /* open/close */
35 _sion_fileptr *_sion_file_open(const char *fname, unsigned int flags, unsigned int addflags);
36 int _sion_file_close( _sion_fileptr *sion_fileptr );
37 
38 /* write/read */
39 sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr );
40 sion_int64 _sion_file_read(void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr );
41 
42 /* utility */
43 int _sion_file_set_second_fileptr( _sion_fileptr *sion_fileptr, FILE* fileptr);
46 int _sion_file_stat_file(const char *fname);
47 
48 sion_int64 _sion_file_set_position(_sion_fileptr *fileptr, sion_int64 startpointer);
49 sion_int64 _sion_file_get_position(_sion_fileptr *fileptr);
50 
51 int _sion_file_flush(_sion_fileptr *fileptr);
52 int _sion_file_purge(_sion_fileptr *fileptr);
53 
54 int _sion_file_set_buffer(_sion_fileptr *fileptr, char *buffer, sion_int32 buffer_size);
55 int _sion_file_get_fd( _sion_fileptr *sion_fileptr);
56 
57 
58 /* ********************************************************************************************** */
59 /* *** Internal INTERFACE Functions (ANSI, POSIX) */
60 /* ********************************************************************************************** */
61 FILE *_sion_file_open_ansi_write_create(const char *fname, unsigned int addflags);
62 FILE *_sion_file_open_ansi_write_existing(const char *fname, unsigned int addflags);
63 FILE *_sion_file_open_ansi_read(const char *fname, unsigned int addflags);
64 int _sion_file_close_ansi(FILE *fileptr);
65 long _sion_file_get_opt_blksize_ansi( FILE *fileptr);
66 sion_int64 _sion_file_set_position_ansi(FILE *fileptr, sion_int64 startpointer);
67 sion_int64 _sion_file_get_position_ansi(FILE *fileptr);
68 int _sion_file_flush_ansi(FILE *fileptr);
69 int _sion_file_purge_ansi(FILE *fileptr);
70 int _sion_file_set_buffer_ansi(FILE *fileptr, char *buffer, sion_int32 buffer_size);
71 sion_int64 _sion_file_write_ansi(const void *data, sion_int64 bytes, FILE *fileptr );
72 sion_int64 _sion_file_read_ansi(void *data, sion_int64 bytes, FILE *fileptr );
73 
74 int _sion_file_open_posix_write_create(const char *fname, unsigned int addflags);
75 int _sion_file_open_posix_write_existing(const char *fname, unsigned int addflags);
76 int _sion_file_open_posix_read(const char *fname, unsigned int addflags);
77 int _sion_file_close_posix(int fd);
79 sion_int64 _sion_file_set_position_posix(int fd, sion_int64 startpointer);
80 sion_int64 _sion_file_get_position_posix(int fd);
81 int _sion_file_flush_posix(int fd);
82 int _sion_file_purge_posix(int fd);
83 int _sion_file_set_buffer_posix(int fd, char *buffer, sion_int32 buffer_size);
84 sion_int64 _sion_file_write_posix(const void *data, sion_int64 bytes, int fd );
85 sion_int64 _sion_file_read_posix(void *data, sion_int64 bytes, int fd );
86 
87 
88 
89 /* ********************************************************************************************** */
90 /* *** Internal Utility Functions */
91 /* ********************************************************************************************** */
93 char* _sion_get_fileptr_desc(_sion_fileptr *sion_fileptr);
94 
95 
96 #endif
int _sion_file_unset_second_fileptr(_sion_fileptr *sion_fileptr)
Unset second fileptr for file if opened with ANSI.
Definition: sion_file.c:405
sion_int64 _sion_file_write_ansi(const void *data, sion_int64 bytes, FILE *fileptr)
ANSI: Write data to file.
Definition: sion_file.c:928
sion_int64 _sion_file_read_ansi(void *data, sion_int64 bytes, FILE *fileptr)
ANSI: Read data from file.
Definition: sion_file.c:955
sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Write data to file.
Definition: sion_file.c:148
int _sion_file_close(_sion_fileptr *sion_fileptr)
Close file and destroys fileptr structure.
Definition: sion_file.c:118
FILE * _sion_file_open_ansi_write_create(const char *fname, unsigned int addflags)
ANSI: Create and open a new file for writing.
Definition: sion_file.c:455
int _sion_file_purge_ansi(FILE *fileptr)
ANSI: Purge the data to the disk.
Definition: sion_file.c:863
char * _sion_get_fileptr_desc(_sion_fileptr *sion_fileptr)
Definition: sion_file.c:1470
int _sion_file_flush_posix(int fd)
POSIX: Flush the data to the disk.
Definition: sion_file.c:1306
long _sion_file_get_opt_blksize(_sion_fileptr *fileptr)
Get optional file system block size for a file.
Definition: sion_file.c:190
int _sion_file_open_posix_write_existing(const char *fname, unsigned int addflags)
POSIX: Open a new file for writing.
Definition: sion_file.c:1022
sion_int64 _sion_file_get_position_ansi(FILE *fileptr)
ANSI: Get the current position in file.
Definition: sion_file.c:773
long _sion_file_get_opt_blksize_posix(int fd)
POSIX: Get optional file system block size for a file.
Definition: sion_file.c:1126
int _sion_file_set_buffer_posix(int fd, char *buffer, sion_int32 buffer_size)
POSIX: set buffer of fd.
Definition: sion_file.c:1356
FILE * _sion_file_open_ansi_write_existing(const char *fname, unsigned int addflags)
ANSI: Open a new file for writing.
Definition: sion_file.c:509
sion_int64 _sion_file_read_posix(void *data, sion_int64 bytes, int fd)
POSIX: Read data from file.
Definition: sion_file.c:1404
int _sion_file_set_buffer(_sion_fileptr *fileptr, char *buffer, sion_int32 buffer_size)
Set buffer of fp.
Definition: sion_file.c:358
int _sion_file_set_buffer_ansi(FILE *fileptr, char *buffer, sion_int32 buffer_size)
ANSI: set buffer of fp.
Definition: sion_file.c:899
sion_int64 _sion_file_get_position_posix(int fd)
POSIX: Get the current position in file.
Definition: sion_file.c:1238
int _sion_file_open_posix_write_create(const char *fname, unsigned int addflags)
POSIX: Create and open a new file for writing.
Definition: sion_file.c:985
int _sion_file_purge_posix(int fd)
POSIX: Purge the data to the disk.
Definition: sion_file.c:1331
int _sion_file_get_fd(_sion_fileptr *sion_fileptr)
Utility function: Get POSIX fp.
Definition: sion_file.c:426
int _sion_file_close_posix(int fd)
POSIX: Close a file.
Definition: sion_file.c:1096
sion_int64 _sion_file_set_position(_sion_fileptr *fileptr, sion_int64 startpointer)
Set new position in file.
Definition: sion_file.c:239
int _sion_file_set_second_fileptr(_sion_fileptr *sion_fileptr, FILE *fileptr)
Set second fileptr for file if opened with ANSI.
Definition: sion_file.c:385
_sion_fileptr * _sion_file_open(const char *fname, unsigned int flags, unsigned int addflags)
Create and open a new file for writing.
Definition: sion_file.c:41
long _sion_file_get_opt_blksize_ansi(FILE *fileptr)
ANSI: Get optional file system block size for a file.
Definition: sion_file.c:645
sion_int64 _sion_file_read(void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Read data from file.
Definition: sion_file.c:169
sion_int64 _sion_file_set_position_ansi(FILE *fileptr, sion_int64 startpointer)
ANSI: Set the start position for the current task.
Definition: sion_file.c:677
sion_int64 _sion_file_write_posix(const void *data, sion_int64 bytes, int fd)
POSIX: Write data to file.
Definition: sion_file.c:1377
int _sion_file_close_ansi(FILE *fileptr)
ANSI: Close a file.
Definition: sion_file.c:617
int _sion_file_flush(_sion_fileptr *fileptr)
Flush data to file.
Definition: sion_file.c:304
int _sion_file_purge(_sion_fileptr *fileptr)
Purge data to file.
Definition: sion_file.c:328
sion_int64 _sion_file_set_position_posix(int fd, sion_int64 startpointer)
POSIX: Set the start position for the current task.
Definition: sion_file.c:1157
int _sion_file_stat_file(const char *fname)
Check if file exists (LARGE_FILE support on BlueGene)
Definition: sion_file.c:210
FILE * _sion_file_open_ansi_read(const char *fname, unsigned int addflags)
ANSI: Open a file for reading.
Definition: sion_file.c:565
sion_int64 _sion_file_get_position(_sion_fileptr *fileptr)
Get new position in file.
Definition: sion_file.c:272
int _sion_file_flush_ansi(FILE *fileptr)
ANSI: Flush the data to the disk.
Definition: sion_file.c:840
_sion_fileptr * _sion_file_alloc_and_init_sion_fileptr()
Create and return _sion_fileptr.
Definition: sion_file.c:1433
int _sion_file_open_posix_read(const char *fname, unsigned int addflags)
POSIX: Open a file for reading.
Definition: sion_file.c:1059