📄 metadata.h
字号:
/**< The chain could not find the FLAC signature at the start of the file */
FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE,
/**< The chain tried to write to a file that was not writable */
FLAC__METADATA_CHAIN_STATUS_BAD_METADATA,
/**< The chain encountered input that does not conform to the FLAC metadata specification */
FLAC__METADATA_CHAIN_STATUS_READ_ERROR,
/**< The chain encountered an error while reading the FLAC file */
FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR,
/**< The chain encountered an error while seeking in the FLAC file */
FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR,
/**< The chain encountered an error while writing the FLAC file */
FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR,
/**< The chain encountered an error renaming the FLAC file */
FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR,
/**< The chain encountered an error removing the temporary file */
FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR,
/**< Memory allocation failed */
FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR,
/**< The caller violated an assertion or an unexpected error occurred */
FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS,
/**< One or more of the required callbacks was NULL */
FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
/**< FLAC__metadata_chain_write() was called on a chain read by
* FLAC__metadata_chain_read_with_callbacks(), or
* FLAC__metadata_chain_write_with_callbacks() or
* FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
* called on a chain read by FLAC__metadata_chain_read(). Matching
* read/write methods must always be used. */
FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL
/**< FLAC__metadata_chain_write_with_callbacks() was called when the
* chain write requires a tempfile; use
* FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead.
* Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
* called when the chain write does not require a tempfile; use
* FLAC__metadata_chain_write_with_callbacks() instead.
* Always check FLAC__metadata_chain_check_if_tempfile_needed()
* before writing via callbacks. */
} FLAC__Metadata_ChainStatus;
/** Maps a FLAC__Metadata_ChainStatus to a C string.
*
* Using a FLAC__Metadata_ChainStatus as the index to this array
* will give the string equivalent. The contents should not be modified.
*/
extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[];
/*********** FLAC__Metadata_Chain ***********/
/** Create a new chain instance.
*
* \retval FLAC__Metadata_Chain*
* \c NULL if there was an error allocating memory, else the new instance.
*/
FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new();
/** Free a chain instance. Deletes the object pointed to by \a chain.
*
* \param chain A pointer to an existing chain.
* \assert
* \code chain != NULL \endcode
*/
FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain);
/** Get the current status of the chain. Call this after a function
* returns \c false to get the reason for the error. Also resets the
* status to FLAC__METADATA_CHAIN_STATUS_OK.
*
* \param chain A pointer to an existing chain.
* \assert
* \code chain != NULL \endcode
* \retval FLAC__Metadata_ChainStatus
* The current status of the chain.
*/
FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain);
/** Read all metadata from a FLAC file into the chain.
*
* \param chain A pointer to an existing chain.
* \param filename The path to the FLAC file to read.
* \assert
* \code chain != NULL \endcode
* \code filename != NULL \endcode
* \retval FLAC__bool
* \c true if a valid list of metadata blocks was read from
* \a filename, else \c false. On failure, check the status with
* FLAC__metadata_chain_status().
*/
FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename);
/** Read all metadata from a FLAC stream into the chain via I/O callbacks.
*
* The \a handle need only be open for reading, but must be seekable.
* The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
* for Windows).
*
* \param chain A pointer to an existing chain.
* \param handle The I/O handle of the FLAC stream to read. The
* handle will NOT be closed after the metadata is read;
* that is the duty of the caller.
* \param callbacks
* A set of callbacks to use for I/O. The mandatory
* callbacks are \a read, \a seek, and \a tell.
* \assert
* \code chain != NULL \endcode
* \retval FLAC__bool
* \c true if a valid list of metadata blocks was read from
* \a handle, else \c false. On failure, check the status with
* FLAC__metadata_chain_status().
*/
FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
/** Checks if writing the given chain would require the use of a
* temporary file, or if it could be written in place.
*
* Under certain conditions, padding can be utilized so that writing
* edited metadata back to the FLAC file does not require rewriting the
* entire file. If rewriting is required, then a temporary workfile is
* required. When writing metadata using callbacks, you must check
* this function to know whether to call
* FLAC__metadata_chain_write_with_callbacks() or
* FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When
* writing with FLAC__metadata_chain_write(), the temporary file is
* handled internally.
*
* \param chain A pointer to an existing chain.
* \param use_padding
* Whether or not padding will be allowed to be used
* during the write. The value of \a use_padding given
* here must match the value later passed to
* FLAC__metadata_chain_write_with_callbacks() or
* FLAC__metadata_chain_write_with_callbacks_with_tempfile().
* \assert
* \code chain != NULL \endcode
* \retval FLAC__bool
* \c true if writing the current chain would require a tempfile, or
* \c false if metadata can be written in place.
*/
FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding);
/** Write all metadata out to the FLAC file. This function tries to be as
* efficient as possible; how the metadata is actually written is shown by
* the following:
*
* If the current chain is the same size as the existing metadata, the new
* data is written in place.
*
* If the current chain is longer than the existing metadata, and
* \a use_padding is \c true, and the last block is a PADDING block of
* sufficient length, the function will truncate the final padding block
* so that the overall size of the metadata is the same as the existing
* metadata, and then just rewrite the metadata. Otherwise, if not all of
* the above conditions are met, the entire FLAC file must be rewritten.
* If you want to use padding this way it is a good idea to call
* FLAC__metadata_chain_sort_padding() first so that you have the maximum
* amount of padding to work with, unless you need to preserve ordering
* of the PADDING blocks for some reason.
*
* If the current chain is shorter than the existing metadata, and
* \a use_padding is \c true, and the final block is a PADDING block, the padding
* is extended to make the overall size the same as the existing data. If
* \a use_padding is \c true and the last block is not a PADDING block, a new
* PADDING block is added to the end of the new data to make it the same
* size as the existing data (if possible, see the note to
* FLAC__metadata_simple_iterator_set_block() about the four byte limit)
* and the new data is written in place. If none of the above apply or
* \a use_padding is \c false, the entire FLAC file is rewritten.
*
* If \a preserve_file_stats is \c true, the owner and modification time will
* be preserved even if the FLAC file is written.
*
* For this write function to be used, the chain must have been read with
* FLAC__metadata_chain_read(), not FLAC__metadata_chain_read_with_callbacks().
*
* \param chain A pointer to an existing chain.
* \param use_padding See above.
* \param preserve_file_stats See above.
* \assert
* \code chain != NULL \endcode
* \retval FLAC__bool
* \c true if the write succeeded, else \c false. On failure,
* check the status with FLAC__metadata_chain_status().
*/
FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats);
/** Write all metadata out to a FLAC stream via callbacks.
*
* (See FLAC__metadata_chain_write() for the details on how padding is
* used to write metadata in place if possible.)
*
* The \a handle must be open for updating and be seekable. The
* equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b"
* for Windows).
*
* For this write function to be used, the chain must have been read with
* FLAC__metadata_chain_read_with_callbacks(), not FLAC__metadata_chain_read().
* Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
* \c false.
*
* \param chain A pointer to an existing chain.
* \param use_padding See FLAC__metadata_chain_write()
* \param handle The I/O handle of the FLAC stream to write. The
* handle will NOT be closed after the metadata is
* written; that is the duty of the caller.
* \param callbacks A set of callbacks to use for I/O. The mandatory
* callbacks are \a write and \a seek.
* \assert
* \code chain != NULL \endcode
* \retval FLAC__bool
* \c true if the write succeeded, else \c false. On failure,
* check the status with FLAC__metadata_chain_status().
*/
FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
/** Write all metadata out to a FLAC stream via callbacks.
*
* (See FLAC__metadata_chain_write() for the details on how padding is
* used to write metadata in place if possible.)
*
* This version of the write-with-callbacks function must be used when
* FLAC__metadata_chain_check_if_tempfile_needed() returns true. In
* this function, you must supply an I/O handle corresponding to the
* FLAC file to edit, and a temporary handle to which the new FLAC
* file will be written. It is the caller's job to move this temporary
* FLAC file on top of the original FLAC file to complete the metadata
* edit.
*
* The \a handle must be open for reading and be seekable. The
* equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
* for Windows).
*
* The \a temp_handle must be open for writing. The
* equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb"
* for Windows). It should be an empty stream, or at least positioned
* at the start-of-file (in which case it is the caller's duty to
* truncate it on return).
*
* For this write function to be used, the chain must have been read with
* FLAC__metadata_chain_read_with_callbacks(), not FLAC__metadata_chain_read().
* Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
* \c true.
*
* \param chain A pointer to an existing chain.
* \param use_padding See FLAC__metadata_chain_write()
* \param handle The I/O handle of the original FLAC stream to read.
* The handle will NOT be closed after the metadata is
* written; that is the duty of the caller.
* \param callbacks A set of callbacks to use for I/O on \a handle.
* The mandatory callbacks are \a read, \a seek, and
* \a eof.
* \param temp_handle The I/O handle of the FLAC stream to write. The
* handle will NOT be closed after the metadata is
* written; that is the duty of the caller.
* \param temp_callbacks
* A set of callbacks to use for I/O on temp_handle.
* The only mandatory callback is \a write.
* \assert
* \code chain != NULL \endcode
* \retval FLAC__bool
* \c true if the write succeeded, else \c false. On failure,
* check the status with FLAC__metadata_chain_status().
*/
FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks);
/** Merge adjacent PADDING blocks into a single block.
*
* \note This function does not write to the FLAC file, it only
* modifies the chain.
*
* \warning Any iterator on the current chain will become invalid after this
* call. You should delete the iterator and get a new one.
*
* \param chain A pointer to an existing chain.
* \assert
* \code chain != NULL \endcode
*/
FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain);
/** This function will move all PADDING blocks to the end on the metadata,
* then merge them into a single block.
*
* \note This function does not write to the FLAC file, it only
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -