Add IsoFileSource implementation for local filesystem.
This commit is contained in:
@ -40,22 +40,52 @@ struct Iso_File_Source
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the path, relative to the filesystem this file source
|
||||
* belongs to.
|
||||
*
|
||||
* @return
|
||||
* 1 success, < 0 error
|
||||
* the path, that belong to the IsoFileSource and should not be
|
||||
* freed by the user.
|
||||
*/
|
||||
const char* (*get_path)(IsoFileSource *src);
|
||||
|
||||
/**
|
||||
* Get information about the file.
|
||||
* @return
|
||||
* 1 success, < 0 error
|
||||
* Error codes:
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int (*lstat)(IsoFileSource *src, struct stat *info);
|
||||
|
||||
//stat?
|
||||
|
||||
/**
|
||||
* Opens the source.
|
||||
* @return 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ALREADY_OPENNED
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int (*open)(IsoFileSource *src);
|
||||
|
||||
|
||||
void (*close)(IsoFileSource *src);
|
||||
/**
|
||||
* Close a previuously openned file
|
||||
* @return 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
*/
|
||||
int (*close)(IsoFileSource *src);
|
||||
|
||||
/**
|
||||
* Attempts to read up to count bytes from the given source into
|
||||
@ -67,6 +97,13 @@ struct Iso_File_Source
|
||||
*
|
||||
* @return
|
||||
* number of bytes read, 0 if EOF, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
* ISO_FILE_IS_DIR
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_INTERRUPTED
|
||||
*/
|
||||
int (*read)(IsoFileSource *src, void *buf, size_t count);
|
||||
|
||||
@ -83,15 +120,63 @@ struct Iso_File_Source
|
||||
* pointer to be filled with the given child. Undefined on error or OEF
|
||||
* @return
|
||||
* 1 on success, 0 if EOF (no more children), < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
* ISO_FILE_IS_NOT_DIR
|
||||
* ISO_MEM_ERROR
|
||||
*/
|
||||
int (*readdir)(IsoFileSource *src, IsoFileSource **child);
|
||||
|
||||
/**
|
||||
* Read the destination of a symlink. You don't need to open the file
|
||||
* to call this.
|
||||
*
|
||||
* @param buf
|
||||
* allocated buffer of at least bufsiz bytes.
|
||||
* The dest. will be copied there, and it will be NULL-terminated
|
||||
* @param bufsiz
|
||||
* characters to be copied. Destination link will be truncated if
|
||||
* it is larger than given size. This include the \0 character.
|
||||
* @return
|
||||
* 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
|
||||
* ISO_FILE_IS_NOT_SYMLINK
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
*
|
||||
*/
|
||||
int (*readlink)(IsoFileSource *src, char *buf, size_t bufsiz);
|
||||
|
||||
/**
|
||||
* Free implementation specific data. Should never be called by user.
|
||||
* Use iso_file_source_unref() instead.
|
||||
*/
|
||||
void (*free)(IsoFileSource *src);
|
||||
|
||||
/*
|
||||
* TODO #00004 Add a get_mime_type() function.
|
||||
* This can be useful for GUI apps, to choose the icon of the file
|
||||
*/
|
||||
|
||||
//TODO define the refcount behavior for FileSources.
|
||||
int refcount;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void iso_file_source_ref(IsoFileSource *src);
|
||||
void iso_file_source_unref(IsoFileSource *src);
|
||||
|
||||
/**
|
||||
* Create a new IsoFileSource from a local filesystem path.
|
||||
* While this is usually called by corresponding method in IsoFilesystem
|
||||
* object, for local filesystem it is legal to call this directly.
|
||||
*/
|
||||
int iso_file_source_new_lfs(char *path, IsoFileSource **src);
|
||||
|
||||
#endif /*LIBISO_FSOURCE_H_*/
|
||||
|
Reference in New Issue
Block a user