📄 metadata.h
字号:
* \retval FLAC__Metadata_SimpleIterator*
* \c NULL if there was an error allocating memory, else the new instance.
*/
FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new();
/** Free an iterator instance. Deletes the object pointed to by \a iterator.
*
* \param iterator A pointer to an existing iterator.
* \assert
* \code iterator != NULL \endcode
*/
FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator);
/** Get the current status of the iterator. Call this after a function
* returns \c false to get the reason for the error. Also resets the status
* to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.
*
* \param iterator A pointer to an existing iterator.
* \assert
* \code iterator != NULL \endcode
* \retval FLAC__Metadata_SimpleIteratorStatus
* The current status of the iterator.
*/
FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator);
/** Initialize the iterator to point to the first metadata block in the
* given FLAC file.
*
* \param iterator A pointer to an existing iterator.
* \param filename The path to the FLAC file.
* \param read_only If \c true, the FLAC file will be opened
* in read-only mode; if \c false, the FLAC
* file will be opened for edit even if no
* edits are performed.
* \param preserve_file_stats If \c true, the owner and modification
* time will be preserved even if the FLAC
* file is written to.
* \assert
* \code iterator != NULL \endcode
* \code filename != NULL \endcode
* \retval FLAC__bool
* \c false if a memory allocation error occurs, the file can't be
* opened, or another error occurs, else \c true.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats);
/** Returns \c true if the FLAC file is writable. If \c false, calls to
* FLAC__metadata_simple_iterator_set_block() and
* FLAC__metadata_simple_iterator_insert_block_after() will fail.
*
* \param iterator A pointer to an existing iterator.
* \assert
* \code iterator != NULL \endcode
* \retval FLAC__bool
* See above.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator);
/** Moves the iterator forward one metadata block, returning \c false if
* already at the end.
*
* \param iterator A pointer to an existing initialized iterator.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \retval FLAC__bool
* \c false if already at the last metadata block of the chain, else
* \c true.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator);
/** Moves the iterator backward one metadata block, returning \c false if
* already at the beginning.
*
* \param iterator A pointer to an existing initialized iterator.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \retval FLAC__bool
* \c false if already at the first metadata block of the chain, else
* \c true.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator);
/** Get the type of the metadata block at the current position. This
* avoids reading the actual block data which can save time for large
* blocks.
*
* \param iterator A pointer to an existing initialized iterator.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \retval FLAC__MetadataType
* The type of the metadata block at the current iterator position.
*/
FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
/** Get the metadata block at the current position. You can modify the
* block but must use FLAC__metadata_simple_iterator_set_block() to
* write it back to the FLAC file.
*
* You must call FLAC__metadata_object_delete() on the returned object
* when you are finished with it.
*
* \param iterator A pointer to an existing initialized iterator.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \retval FLAC__StreamMetadata*
* The current metadata block.
*/
FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator);
/** Write a block back to the FLAC file. This function tries to be
* as efficient as possible; how the block is actually written is
* shown by the following:
*
* Existing block is a STREAMINFO block and the new block is a
* STREAMINFO block: the new block is written in place. Make sure
* you know what you're doing when changing the values of a
* STREAMINFO block.
*
* Existing block is a STREAMINFO block and the new block is a
* not a STREAMINFO block: this is an error since the first block
* must be a STREAMINFO block. Returns \c false without altering the
* file.
*
* Existing block is not a STREAMINFO block and the new block is a
* STREAMINFO block: this is an error since there may be only one
* STREAMINFO block. Returns \c false without altering the file.
*
* Existing block and new block are the same length: the existing
* block will be replaced by the new block, written in place.
*
* Existing block is longer than new block: if use_padding is \c true,
* the existing block will be overwritten in place with the new
* block followed by a PADDING block, if possible, to make the total
* size the same as the existing block. Remember that a padding
* block requires at least four bytes so if the difference in size
* between the new block and existing block is less than that, the
* entire file will have to be rewritten, using the new block's
* exact size. If use_padding is \c false, the entire file will be
* rewritten, replacing the existing block by the new block.
*
* Existing block is shorter than new block: if use_padding is \c true,
* the function will try and expand the new block into the following
* PADDING block, if it exists and doing so won't shrink the PADDING
* block to less than 4 bytes. If there is no following PADDING
* block, or it will shrink to less than 4 bytes, or use_padding is
* \c false, the entire file is rewritten, replacing the existing block
* with the new block. Note that in this case any following PADDING
* block is preserved as is.
*
* After writing the block, the iterator will remain in the same
* place, i.e. pointing to the new block.
*
* \param iterator A pointer to an existing initialized iterator.
* \param block The block to set.
* \param use_padding See above.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \code block != NULL \endcode
* \retval FLAC__bool
* \c true if successful, else \c false.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
/** This is similar to FLAC__metadata_simple_iterator_set_block()
* except that instead of writing over an existing block, it appends
* a block after the existing block. \a use_padding is again used to
* tell the function to try an expand into following padding in an
* attempt to avoid rewriting the entire file.
*
* This function will fail and return \c false if given a STREAMINFO
* block.
*
* After writing the block, the iterator will be pointing to the
* new block.
*
* \param iterator A pointer to an existing initialized iterator.
* \param block The block to set.
* \param use_padding See above.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \code block != NULL \endcode
* \retval FLAC__bool
* \c true if successful, else \c false.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
/** Deletes the block at the current position. This will cause the
* entire FLAC file to be rewritten, unless \a use_padding is \c true,
* in which case the block will be replaced by an equal-sized PADDING
* block. The iterator will be left pointing to the block before the
* one just deleted.
*
* You may not delete the STREAMINFO block.
*
* \param iterator A pointer to an existing initialized iterator.
* \param use_padding See above.
* \assert
* \code iterator != NULL \endcode
* \a iterator has been successfully initialized with
* FLAC__metadata_simple_iterator_init()
* \retval FLAC__bool
* \c true if successful, else \c false.
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding);
/* \} */
/** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface
* \ingroup flac_metadata
*
* \brief
* The level 2 interface provides read-write access to FLAC file metadata;
* all metadata is read into memory, operated on in memory, and then written
* to file, which is more efficient than level 1 when editing multiple blocks.
*
* The general usage of this interface is:
*
* - Create a new chain using FLAC__metadata_chain_new(). A chain is a
* linked list of FLAC metadata blocks.
* - Read all metadata into the the chain from a FLAC file using
* FLAC__metadata_chain_read() and check the status.
* - Optionally, consolidate the padding using
* FLAC__metadata_chain_merge_padding() or
* FLAC__metadata_chain_sort_padding().
* - Create a new iterator using FLAC__metadata_iterator_new()
* - Initialize the iterator to point to the first element in the chain
* using FLAC__metadata_iterator_init()
* - Traverse the chain using FLAC__metadata_iterator_next and
* FLAC__metadata_iterator_prev().
* - Get a block for reading or modification using
* FLAC__metadata_iterator_get_block(). The pointer to the object
* inside the chain is returned, so the block is yours to modify.
* Changes will be reflected in the FLAC file when you write the
* chain. You can also add and delete blocks (see functions below).
* - When done, write out the chain using FLAC__metadata_chain_write().
* Make sure to read the whole comment to the function below.
* - Delete the chain using FLAC__metadata_chain_delete().
*
* \note
* Even though the FLAC file is not open while the chain is being
* manipulated, you must not alter the file externally during
* this time. The chain assumes the FLAC file will not change
* between the time of FLAC__metadata_chain_read() and
* FLAC__metadata_chain_write().
*
* \note
* Do not modify the is_last, length, or type fields of returned
* FLAC__StreamMetadata objects. These are managed automatically.
*
* \note
* The metadata objects returned by FLAC__metadata_iterator_get_block()
* are owned by the chain; do not FLAC__metadata_object_delete() them.
* In the same way, blocks passed to FLAC__metadata_iterator_set_block()
* become owned by the chain and they will be deleted when the chain is
* deleted.
*
* \{
*/
struct FLAC__Metadata_Chain;
/** The opaque structure definition for the level 2 chain type.
*/
typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain;
struct FLAC__Metadata_Iterator;
/** The opaque structure definition for the level 2 iterator type.
*/
typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator;
typedef enum {
FLAC__METADATA_CHAIN_STATUS_OK = 0,
/**< The chain is in the normal OK state */
FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT,
/**< The data passed into a function violated the function's usage criteria */
FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE,
/**< The chain could not open the target file */
FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -