dmlite
0.4
Main Page
Namespaces
Classes
Files
File List
File Members
include
dmlite
c
io.h
Go to the documentation of this file.
1
/** @file include/dmlite/c/io.h
2
* @brief C wrapper for I/O interfaces.
3
* @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
4
*/
5
#ifndef DMLITE_IO_H
6
#define DMLITE_IO_H
7
8
#include "
any.h
"
9
#include "
dmlite.h
"
10
11
#ifdef __cplusplus
12
extern
"C"
{
13
#endif
14
15
/** Handle for a file descriptor. */
16
typedef
struct
dmlite_fd
dmlite_fd
;
17
18
/**
19
* @brief Opens a file.
20
* @param context The DM context.
21
* @param path The path to open.
22
* @param flags See open()
23
* @param extra The key-value pairs.
24
* @return An opaque handler for the file, NULL on failure.
25
*/
26
dmlite_fd
*
dmlite_fopen
(
dmlite_context
* context,
const
char
* path,
int
flags,
27
const
dmlite_any_dict
* extra);
28
29
/**
30
* @brief Closes a file.
31
* @param fd The file descriptor as returned by dmlite_open.
32
* @return 0 on sucess, error code otherwise.
33
*/
34
int
dmlite_fclose
(
dmlite_fd
* fd);
35
36
/**
37
* @brief Sets the file position.
38
* @param fd The file descriptor.
39
* @param offset The offset.
40
* @param whence See fseek()
41
* @return 0 on sucess, error code otherwise.
42
*/
43
int
dmlite_fseek
(
dmlite_fd
* fd,
long
offset,
int
whence);
44
45
/**
46
* @brief Returns the cursor position.
47
* @param fd The file descriptor.
48
* @return The cursor position, or -1 on error.
49
*/
50
long
dmlite_ftell
(
dmlite_fd
* fd);
51
52
/**
53
* @brief Reads from a file.
54
* @param fd The file descriptor.
55
* @param buffer Where to put the data.
56
* @param count Number of bytes to read.
57
* @return Number of bytes actually read on success. -1 on failure.
58
*/
59
size_t
dmlite_fread
(
dmlite_fd
* fd,
void
* buffer,
size_t
count);
60
61
/**
62
* @brief Writes to a file.
63
* @param fd The file descriptor.
64
* @param buffer A pointer to the data.
65
* @param count Number of bytes to write.
66
* @return Number of bytes actually written. -1 on failure.
67
*/
68
size_t
dmlite_fwrite
(
dmlite_fd
* fd,
const
void
* buffer,
size_t
count);
69
70
/**
71
* @brief Returns 1 if EOF.
72
* @param fd The file descriptor.
73
* @return 0 if there is more to read. 1 if EOF.
74
*/
75
int
dmlite_feof
(
dmlite_fd
* fd);
76
77
/**
78
* @brief Finishes a PUT.
79
* @param context The DM context.
80
* @param pfn The replica file name.
81
* @param extra The extra parameters as returned by dmlite_put.
82
* @return 0 on success, error code otherwise.
83
*/
84
int
dmlite_donewriting
(
dmlite_context
* context,
85
const
char
* pfn,
86
const
dmlite_any_dict
* extra);
87
88
#ifdef __cplusplus
89
}
90
#endif
91
92
#endif
/* DMLITE_IO_H */
Generated on Tue Jan 22 2013 02:19:46 for dmlite by
1.8.1.1