Changed tree, re-implemented and fixed a lot of problematic areas
This commit is contained in:
@@ -33,11 +33,44 @@ struct iso_volset;
|
||||
*/
|
||||
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.
|
||||
@@ -49,7 +82,7 @@ struct iso_volume *iso_volume_new(const char *volume_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 *root);
|
||||
struct iso_tree_node_dir *root);
|
||||
|
||||
/**
|
||||
* Free a volume.
|
||||
@@ -64,7 +97,7 @@ void iso_volset_free(struct iso_volset *volume);
|
||||
/**
|
||||
* Get the root directory for a volume.
|
||||
*/
|
||||
struct iso_tree_node *iso_volume_get_root(const struct iso_volume *volume);
|
||||
struct iso_tree_node_dir *iso_volume_get_root(const struct iso_volume *volume);
|
||||
|
||||
/**
|
||||
* Fill in the volume identifier for a volume.
|
||||
@@ -126,7 +159,7 @@ void iso_volume_set_biblio_file_id(struct iso_volume *volume,
|
||||
* \return The node found or NULL.
|
||||
*
|
||||
*/
|
||||
struct iso_tree_node *iso_tree_volume_path_to_node(struct iso_volume *volume, const char *path);
|
||||
//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.
|
||||
@@ -137,9 +170,9 @@ struct iso_tree_node *iso_tree_volume_path_to_node(struct iso_volume *volume, co
|
||||
*
|
||||
* \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);
|
||||
//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.
|
||||
@@ -149,8 +182,8 @@ struct iso_tree_node *iso_tree_volume_add_path(struct iso_volume *volume,
|
||||
*
|
||||
* \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);
|
||||
//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.
|
||||
@@ -161,54 +194,96 @@ struct iso_tree_node *iso_tree_volume_add_new_dir(struct iso_volume *volume,
|
||||
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 NULL or is a directory.
|
||||
* \pre \p path is non-NULL and is a valid path to a non-directory on the local
|
||||
* \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 *parent,
|
||||
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 and iso_tree_add_dir.
|
||||
* 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 NULL or is a directory.
|
||||
* \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 *iso_tree_radd_dir(struct iso_tree_node *parent,
|
||||
const char *path);
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Add the path of a file or directory to ignore when adding a directory recursively.
|
||||
*
|
||||
* \param path The path, on the local filesystem, of the file.
|
||||
*/
|
||||
void iso_exclude_add_path(const char *path);
|
||||
|
||||
/**
|
||||
* Remove a path that was set to be ignored when adding a directory recusively.
|
||||
*
|
||||
* \param path The path, on the local filesystem, of the file.
|
||||
*/
|
||||
void iso_exclude_remove_path(const char *path);
|
||||
|
||||
/**
|
||||
* Remove all paths that were set to be ignored when adding a directory recusively.
|
||||
*/
|
||||
void iso_exclude_empty(void);
|
||||
//struct iso_tree_node *iso_tree_radd_dir(struct iso_tree_node *parent,
|
||||
// const char *path);
|
||||
|
||||
/**
|
||||
* Creates a new, empty directory on the volume.
|
||||
@@ -221,13 +296,18 @@ void iso_exclude_empty(void);
|
||||
* 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);
|
||||
/*struct iso_tree_node *iso_tree_add_new_dir(struct iso_tree_node *parent,
|
||||
const char *name);*/
|
||||
|
||||
/**
|
||||
* Set the name of a file (using the current locale).
|
||||
* Set the name of a tree node (using the current locale).
|
||||
*/
|
||||
void iso_tree_node_set_name(struct iso_tree_node *file, const char *name);
|
||||
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.
|
||||
|
Reference in New Issue
Block a user