libisofs-legacy/libisofs/libisofs.h

339 lines
10 KiB
C
Executable File

/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* vim: set noet ts=8 sts=8 sw=8 : */
/**
* Create an ISO-9660 data volume with Rock Ridge and Joliet extensions.
* Usage is easy:
* - Create a new volume.
* - Add files and directories.
* - Write the volume to a file or create a burn source for use with Libburn.
*/
#ifndef LIBISO_LIBISOFS_H
#define LIBISO_LIBISOFS_H
/* #include <libburn.h> */
struct burn_source;
/**
* Data volume.
* @see volume.h for details.
*/
struct iso_volume;
/**
* A set of data volumes.
* @see volume.h for details.
*/
struct iso_volset;
/**
* A node in the filesystem tree.
* \see tree.h
*/
struct iso_tree_node;
/**
* A directory in the filesystem tree.
* The first member of this is an iso_tree_node.
* \see tree.h
*/
struct iso_tree_node_dir;
enum ecma119_extension_flag {
ECMA119_ROCKRIDGE = (1<<0),
ECMA119_JOLIET = (1<<1)
};
/**
* This will hold the error code for some functions, if them fail.
*/
int libisofs_errno;
/* an unexpected internal error */
#define INTERNAL_ERROR -1
/* file don't exists, or can't be stat'ed */
#define NO_FILE 1
/* user haven't read access to file */
#define NO_READ_ACCESS 2
/* unexpected file type, eg., passing a dir instead of a regular file */
#define UNEXPECTED_FILE_TYPE 3
/**
* Controls the bahavior of iso_tree_radd_dir function
*/
struct iso_tree_radd_dir_behavior {
char** excludes; /**< List of paths (file or directory) to be ignored. */
//int follow_sym_link;
int stop_on_error; /**< Stop when an error was found?. */
int error; /**< set to 1 on error */
//int notify_errors;
//char** errors;
};
/**
* Create a new volume.
* The parameters can be set to NULL if you wish to set them later.
*/
struct iso_volume *iso_volume_new(const char *volume_id,
const char *publisher_id,
const char *data_preparer_id);
struct iso_volume *iso_volume_new_with_root(const char *volume_id,
const char *publisher_id,
const char *data_preparer_id,
struct iso_tree_node_dir *root);
/**
* Free a volume.
*/
void iso_volume_free(struct iso_volume *volume);
/**
* Free a set of data volumes.
*/
void iso_volset_free(struct iso_volset *volume);
/**
* Get the root directory for a volume.
*/
struct iso_tree_node_dir *iso_volume_get_root(const struct iso_volume *volume);
/**
* Fill in the volume identifier for a volume.
*/
void iso_volume_set_volume_id(struct iso_volume *volume,
const char *volume_id);
/**
* Fill in the publisher for a volume.
*/
void iso_volume_set_publisher_id(struct iso_volume *volume,
const char *publisher_id);
/**
* Fill in the data preparer for a volume.
*/
void iso_volume_set_data_preparer_id(struct iso_volume *volume,
const char *data_preparer_id);
/**
* Fill in the system id for a volume. Up to 32 characters.
*/
void iso_volume_set_system_id(struct iso_volume *volume,
const char *system_id);
/**
* Fill in the application id for a volume. Up to 128 chars.
*/
void iso_volume_set_application_id(struct iso_volume *volume,
const char *application_id);
/**
* Fill copyright information for the volume. Usually this refers
* to a file on disc. Up to 37 characters.
*/
void iso_volume_set_copyright_file_id(struct iso_volume *volume,
const char *copyright_file_id);
/**
* Fill abstract information for the volume. Usually this refers
* to a file on disc. Up to 37 characters.
*/
void iso_volume_set_abstract_file_id(struct iso_volume *volume,
const char *abstract_file_id);
/**
* Fill biblio information for the volume. Usually this refers
* to a file on disc. Up to 37 characters.
*/
void iso_volume_set_biblio_file_id(struct iso_volume *volume,
const char *biblio_file_id);
/**
* Locate a node by its path on disc.
*
* \param volume The volume to search in.
* \param path The path, in the image, of the file.
*
* \return The node found or NULL.
*
*/
//struct iso_tree_node *iso_tree_volume_path_to_node(struct iso_volume *volume, const char *path);
/**
* Add a file or a directory (recursively) to a volume by specifying its path on the volume.
*
* \param volume The volume to add the file to.
* \param disc_path The path on the disc at which to add the disc.
* \param path The path, on the local filesystem, of the file.
*
* \return The node for the file or NULL if the parent doesn't exists on the disc.
*/
//struct iso_tree_node *iso_tree_volume_add_path(struct iso_volume *volume,
// const char *disc_path,
// const char *path);
/**
* Creates a new, empty directory on the volume.
*
* \param volume The volume to add the directory to.
* \param disc_path The path on the volume at which to add the directory.
*
* \return A pointer to the newly created directory.
*/
//struct iso_tree_node *iso_tree_volume_add_new_dir(struct iso_volume *volume,
// const char *disc_path);
/**
* Create a new Volume Set consisting of only one volume.
* @param volume The first and only volume for the volset to contain.
* @param volset_id The Volume Set ID.
* @return A new iso_volset.
*/
struct iso_volset *iso_volset_new(struct iso_volume *volume,
const char *volset_id);
/**
* Creates a new root dir for a filesystem tree
*/
struct iso_tree_node_dir *iso_tree_new_root();
/**
* Add a file to a directory.
*
* \param path The path, on the local filesystem, of the file.
*
* \pre \p parent is non-NULL.
* \pre \p path is non-NULL.
* \return An iso_tree_node_file whose path is \p path and whose parent is
* \p parent.
* On error, returns NULL and libisofs_errno is set appropriately:
* NO_FILE if path doesn't point to a valid file.
* NO_READ_ACCESS if user haven't read access on file
* UNEXPECTED_FILE_TYPE if path doesn't point to a regular file
*/
struct iso_tree_node *iso_tree_add_file(struct iso_tree_node_dir *parent,
const char *path);
/**
* Add a symbolic link to a directory.
*
* \param name The name of the symbolic link
* \param dest The distination of the link, i.e., the file this link points
* to
*
* \pre \p parent, name and dest are non-NULL.
*
* \return An iso_tree_node_symlink
*/
struct iso_tree_node *iso_tree_add_symlink(struct iso_tree_node_dir *parent,
const char *name, const char *dest);
/**
* Add a new, empty directory to the tree.
*
* \pre \p parent is non-NULL.
* \pre \p name is unique among the children and files belonging to \p parent.
* Also, it doesn't contain '/' characters.
*
* \post \p parent contains a child directory whose name is \p name and whose
* POSIX attributes are the same as \p parent's.
* \return a pointer to the newly created directory.
*/
struct iso_tree_node_dir *iso_tree_add_dir(struct iso_tree_node_dir *parent,
const char *name);
/* TODO iso_tree_new_special */
/**
* Add a file to a directory.
*
* \param path The path, on the local filesystem, of the file.
*
* \pre \p parent is non-NULL.
* \pre \p path is non-NULL and is a valid path to a file or directory on the local
* filesystem.
* \return An iso_tree_node whose path is \p path and whose parent is \p parent.
* On error, returns NULL and libisofs_errno is set appropriately:
* NO_FILE if path doesn't point to a valid file.
* NO_READ_ACCESS if user haven't read access on file
* UNEXPECTED_FILE_TYPE if path refers to non supported file type
* (at the momment, only dirs, symlinks and regular
* files are supported).
*/
struct iso_tree_node *iso_tree_add_node(struct iso_tree_node_dir *parent,
const char *path);
/**
* Recursively add an existing directory to the tree.
* Warning: when using this, you'll lose pointers to files or subdirectories.
* If you want to have pointers to all files and directories,
* use iso_tree_add_file, iso_tree_add_node and iso_tree_add_dir.
*
* \param path The path, on the local filesystem, of the directory to add.
*
* \pre \p parent is non-NULL.
* \pre \p path is non-NULL and is a valid path to a directory on the local
* filesystem.
* \return a pointer to the newly created directory.
*/
struct iso_tree_node_dir *iso_tree_radd_dir(struct iso_tree_node_dir *parent,
const char *path, struct iso_tree_radd_dir_behavior *behavior);
//struct iso_tree_node *iso_tree_radd_dir(struct iso_tree_node *parent,
// const char *path);
/**
* Creates a new, empty directory on the volume.
*
* \pre \p parent is NULL or is a directory.
* \pre \p name is unique among the children and files belonging to \p parent.
* Also, it doesn't contain '/' characters.
*
* \post \p parent contains a child directory whose name is \p name and whose
* POSIX attributes are the same as \p parent's.
* \return a pointer to the newly created directory.
*/
/*struct iso_tree_node *iso_tree_add_new_dir(struct iso_tree_node *parent,
const char *name);*/
/**
* Set the name of a tree node (using the current locale).
*/
void iso_tree_node_set_name(struct iso_tree_node *node, const char *name);
/**
* Set if the node will be hidden in RR/ISO tree, Joliet tree or both.
*/
void iso_tree_node_set_hidden(struct iso_tree_node *node, int hide_attrs);
/**
* Recursively print a directory to stdout.
* \param spaces The initial number of spaces on the left. Set to 0 if you
* supply a root directory.
*/
void iso_tree_print(const struct iso_tree_node *root, int spaces);
/** Create a burn_source which can be used as a data source for a track
*
* The volume set used to create the libburn_source can _not_ be modified
* until the libburn_source is freed.
*
* \param volumeset The volume set from which you want to write
* \param volnum The volume in the set which you want to write (usually 0)
* \param level ISO level to write at.
* \param flags Which extensions to support.
*
* \pre \p volumeset is non-NULL
* \pre \p volnum is less than \p volset->volset_size.
* \return A burn_source to be used for the data source for a track
*/
struct burn_source* iso_source_new_ecma119 (struct iso_volset *volumeset,
int volnum,
int level,
int flags);
#endif /* LIBISO_LIBISOFS_H */