Main Page | Data Structures | File List | Data Fields | Globals

ioclient.h File Reference

#include "glite/data/io/client/iotypes.h"
#include <fcntl.h>

Go to the source code of this file.

Defines

#define GLITE_IO_SD_TYPE   "org.glite.gliteIO"
#define GLITE_IO_SD_ENV   "GLITE_SD_GLITEIO_TYPE"
#define GLITE_IO_URL_PREFIX   "gliteio://"
#define TOOL_USER_VERBOSE   "__GLITE_IO_VERBOSE"

Functions

bool is_gliteio_url (const char *string)
 Check if string is in form "gliteio://...".

int glite_io_initialize (const char *endpoint, const bool encryptdata)
 Initialize the service.

void glite_io_finalize ()
 Finalize a service.

glite_handle glite_open (const char *pathname, glite_int32 flags, glite_int32 mode, glite_int64 size, glite_result *result)
 Open a Remote File.

glite_handle glite_creat (const char *pathname, glite_int32 mode, glite_int64 size, glite_result *result)
 Create a Remote File.

glite_int32 glite_read (glite_handle fh, void *buf, glite_int32 count)
 Read the file.

glite_int32 glite_write (glite_handle fh, const void *buf, glite_int32 count)
 Write to the file.

glite_int64 glite_lseek (glite_handle fh, glite_int64 offset, glite_int32 whence)
 Set a file read/write pointer.

glite_int32 glite_fstat (glite_handle fh, struct glite_stat *buf)
 Get Information about the file associated with the given handle.

glite_int32 glite_close (glite_handle fh)
 Close the file.

glite_int32 glite_unlink (const char *pathname)
 Deletes a file on the remote Storage element.

glite_int32 glite_error (glite_handle fh)
 Get the Last GLite Error code associated to a File Handle.

const char * glite_strerror (glite_result error)
 Get a string representing a GLite Error code TODO Define GLite Error Codes (now the aiod ones are used)
.


Define Documentation

#define GLITE_IO_SD_ENV   "GLITE_SD_GLITEIO_TYPE"
 

Definition at line 29 of file ioclient.h.

#define GLITE_IO_SD_TYPE   "org.glite.gliteIO"
 

Definition at line 26 of file ioclient.h.

#define GLITE_IO_URL_PREFIX   "gliteio://"
 

Definition at line 32 of file ioclient.h.

#define TOOL_USER_VERBOSE   "__GLITE_IO_VERBOSE"
 

Definition at line 35 of file ioclient.h.


Function Documentation

glite_int32 glite_close glite_handle  fh  ) 
 

Close the file.

Parameters:
fh [IN] the file handle returned by a previos glite_open or glite_creat call
Returns:
GLITE_IO_SUCCESS if success, a negative value in case of error

glite_handle glite_creat const char *  pathname,
glite_int32  mode,
glite_int64  size,
glite_result result
 

Create a Remote File.

This call is equivalent to glite_open(name, O_CREAT, mode, server, options)

Parameters:
pathname [IN] the name of the remote file to open. It could be in the format lfn://<file_name> or guid:<file_guid>. glite_creat also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
mode [IN] specifies what permissions the file has when it is created
size [IN] specifies how many bytes should be preallocated remotely. May be null
result [OUT] the result code associated with the operation. This parameter is used to return additional information in case of errors and can be null if that information is not requested
Returns:
a handle to the opened file, or GLITE_NULL_HANDLE in case of failure

glite_int32 glite_error glite_handle  fh  ) 
 

Get the Last GLite Error code associated to a File Handle.


This method cannot be used after an open or close call, since there's no valid file handle
TODO Define GLite Error Codes (now the aiod ones are used)

Parameters:
fh [IN] the file handle returned by a previos glite_open or glite_creat call
Returns:
GLITE_IO_SUCCESS if success, a negative value in case of error

glite_int32 glite_fstat glite_handle  fh,
struct glite_stat buf
 

Get Information about the file associated with the given handle.

Parameters:
fh [IN] the file handle returned by a previos glite_open or glite_creat call
buf [OUT] pointer to a stat structure, as defined in iotypes.h, into which information is placed concerning the file
Returns:
GLITE_IO_SUCCESS if success, or a negative value in case of error

void glite_io_finalize  ) 
 

Finalize a service.

int glite_io_initialize const char *  endpoint,
const bool  encryptdata
 

Initialize the service.

Parameters:
endpoint [IN] user-given service endpoint or NULL
encryptdata [IN] user-given data encryption or false
Returns:
0 on success, -1 on error

glite_int64 glite_lseek glite_handle  fh,
glite_int64  offset,
glite_int32  whence
 

Set a file read/write pointer.

Parameters:
fh [IN] the file handle returned by a previos glite_open or glite_creat call
offset [IN] new byte offset to seek to
whence [IN] relative file position. it can be one of the following values:
SEEK_SET - set to offset
SEEK_CUR - set to current position plus offset
SEEK_END - set to the size of the file plus offset
Returns:
The new offset from the beginning of the file, or a negative value in case of error

glite_handle glite_open const char *  pathname,
glite_int32  flags,
glite_int32  mode,
glite_int64  size,
glite_result result
 

Open a Remote File.

Parameters:
pathname [IN] the name of the remote file to open. It could be in the format lfn://<file_name> or guid:lt;file_guid>. glite_open also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
flags [IN] the requested access flag. The value should be a the bitwise inclusive-OR of values from the following lists:
O_RDONLY - open for reading only
O_WRONLY - open for writing only
O_CREAT - create a file
mode [IN] specifies what permissions the file has when it is created
size [IN] specifies how many bytes should be preallocated remotely. It will be used only if the O_CREAT flag is set and may be null
result [OUT] the result code associated with the operation. This parameter is used to return additional information in case of errors and can be null if that information is not requested
Returns:
a handle to the opened file, or GLITE_NULL_HANDLE in case of failure

glite_int32 glite_read glite_handle  fh,
void *  buf,
glite_int32  count
 

Read the file.

Parameters:
fh [IN] the file handle returned by a previos glite_open call
buf [IN] the buffer where to store the data
count [IN] the number of byte to read. This parameter should be equal or less the size of the buffer
Returns:
the number of bytes read, or a negative value in case of error

const char* glite_strerror glite_result  error  ) 
 

Get a string representing a GLite Error code TODO Define GLite Error Codes (now the aiod ones are used)
.

Parameters:
error [IN] the error code to be translated
Returns:
the error strig

glite_int32 glite_unlink const char *  pathname  ) 
 

Deletes a file on the remote Storage element.

That replica information will be removed from the Logical File System and an attempt is made to remove the physical instance, but if that fails no error are returned. In case that replica is the last one, also the file logical name and GUID will be removed, so they can be reused later TODO Define GLite Error Codes (now the aiod ones are used)

Parameters:
pathname [IN] the name of the remote file to delete. It could be in the format lfn://<file_name> or guid:<file_guid>. glite_unlink also accept the file name without the prefix: In that case if file_name starts with a '/' is interpreted as an LFN; otherwise if it's a valid GUID string representation, it's interpreted as a GUID
Returns:
GLITE_IO_SUCCESS if success, a negative value in case of error

glite_int32 glite_write glite_handle  fh,
const void *  buf,
glite_int32  count
 

Write to the file.

Parameters:
fh [IN] the file handle returned by a previos glite_open or glite_creat call
buf [IN] the buffer containing the data to be written
count [IN] the number of byte to write. This parameter should be equal or less the size of the buffer
Returns:
the number of bytes written, or a negative value in case of error

bool is_gliteio_url const char *  string  ) 
 

Check if string is in form "gliteio://...".

Parameters:
string [IN] the string to check
Returns:
true is string is in form above, false if not
The GLite Project. All rights reserved.