Main Page   Compound List   File List   Compound Members   File Members  

lib/container/dir.c File Reference

Container placed in a directory. More...

#include "../gobj/container.h"
#include "../gobj/ids.h"
#include "../gobj/errors.h"
#include "../gobj/utils.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>

Compounds

struct  Gj_Container_struct

Defines

#define BASEDIR   GJ_DATADIR "/containers/"
 Base container directory.

#define DIRPREFIX   "cid"
 Directory prefix.

#define FILEPREFIX   "obj"
 Filename prefix.

#define FILESUFFIX   ".bin"
 Filename suffix.

#define MAXFILENAMELEN   20
 Max len of a filename.


Functions

int gj_container_touch (Gj_Ctx* ctx, char* name)
 "Touch" a file via the stream function. More...

Gj_ContainerGj_container_new (Gj_Ctx* ctx, Gj_Id* id)
 Create a new container. More...

Gj_ContainerGj_container_create (Gj_Ctx* ctx, Gj_Stream* stream)
 Create a container from a stream. More...

Gj_ContainerGj_container_open (Gj_Ctx* ctx, Gj_Id* id, char* name)
 Open the container specified by its id or its name. More...

int Gj_container_delete (Gj_Ctx* ctx, Gj_Container* container)
 Delete the given container. More...

int Gj_container_destroy (Gj_Ctx* ctx, Gj_Container* container)
 Destroy the given container PHYSICALLY. More...

int Gj_container_write (Gj_Ctx* ctx, Gj_Container* container, Gj_Stream* stream)
 Write the given container to a stream. More...

int Gj_container_setName (Gj_Ctx* ctx, Gj_Container* container, char* name)
 Set the name of the container. More...

Gj_IdGj_container_getId (Gj_Ctx* ctx, Gj_Container* container)
 Get the id of the container. More...

Gj_ContainerId Gj_container_getNewId (Gj_Ctx* ctx, Gj_Container* container)
 Get a new container id. More...

int Gj_container_releaseId (Gj_Ctx* ctx, Gj_Container* container, Gj_ContainerId id)
 Release a container id and thus destroy the data linked with it. More...

int Gj_container_clear (Gj_Ctx* ctx, Gj_Container* container)
 Clear the container (i.e. delete all data saved in it). More...

Gj_StreamGj_container_getStream (Gj_Ctx* ctx, Gj_Container* container, Gj_ContainerId id)
 Ask for a stream to do I/O on a given container id. More...

int Gj_container_releaseStream (Gj_Ctx* ctx, Gj_Container* container, Gj_ContainerId id, Gj_Stream* stream)
 Release a used stream. More...


Detailed Description

Container placed in a directory.


Function Documentation

int gj_container_touch ( Gj_Ctx * ctx,
char * name )
 

"Touch" a file via the stream function.

Returns:
0 on success, -1 otherwise.

For internal use only.

Gj_Container * Gj_container_new ( Gj_Ctx * ctx,
Gj_Id * id )
 

Create a new container.

If

(id != 0) 
use the given id as the container id, else create a new id.

Returns:
A pointer to the new container on success, 0 otherwise.

Gj_Container * Gj_container_create ( Gj_Ctx * ctx,
Gj_Stream * stream )
 

Create a container from a stream.

Returns:
A pointer to the new container on success, 0 otherwise.

Gj_Container * Gj_container_open ( Gj_Ctx * ctx,
Gj_Id * id,
char * name )
 

Open the container specified by its id or its name.

Returns:
A pointer to the container on success, 0 otherwise.

int Gj_container_delete ( Gj_Ctx * ctx,
Gj_Container * container )
 

Delete the given container.

The container is NOT PHYSICALLY deleted.

Returns:
0 on success, -1 otherwise.

int Gj_container_destroy ( Gj_Ctx * ctx,
Gj_Container * container )
 

Destroy the given container PHYSICALLY.

Returns:
0 on success, -1 otherwise.

int Gj_container_write ( Gj_Ctx * ctx,
Gj_Container * container,
Gj_Stream * stream )
 

Write the given container to a stream.

Returns:
0 on success, -1 otherwise.

int Gj_container_setName ( Gj_Ctx * ctx,
Gj_Container * container,
char * name )
 

Set the name of the container.

The string is BEING DUPLICATED.

Returns:
0 on success, -1 otherwise.

Gj_Id * Gj_container_getId ( Gj_Ctx * ctx,
Gj_Container * container )
 

Get the id of the container.

The id is STILL OWNED by the container.

Gj_ContainerId Gj_container_getNewId ( Gj_Ctx * ctx,
Gj_Container * container )
 

Get a new container id.

Returns:
the container id on success, 0 otherwise.

int Gj_container_releaseId ( Gj_Ctx * ctx,
Gj_Container * container,
Gj_ContainerId id )
 

Release a container id and thus destroy the data linked with it.

Returns:
0 on success, -1 otherwise.

int Gj_container_clear ( Gj_Ctx * ctx,
Gj_Container * container )
 

Clear the container (i.e. delete all data saved in it).

Returns:
0 on success, -1 otherwise.

Gj_Stream * Gj_container_getStream ( Gj_Ctx * ctx,
Gj_Container * container,
Gj_ContainerId id )
 

Ask for a stream to do I/O on a given container id.

Returns:
A pointer to the stream on success, 0 otherwise.

int Gj_container_releaseStream ( Gj_Ctx * ctx,
Gj_Container * container,
Gj_ContainerId id,
Gj_Stream * stream )
 

Release a used stream.

Returns:
0 on success, -1 otherwise.


Generated at Fri Aug 17 18:28:56 2001 for Gobj by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000