summaryrefslogtreecommitdiff
path: root/src/libFLAC/metadata_iterators.c
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2013-03-21 19:18:49 +1100
committerErik de Castro Lopo <erikd@mega-nerd.com>2013-03-29 21:25:59 +1100
commit5705b4d7b2c3c5311138e9f4b66658c51f3cc22b (patch)
treee96ada937e8b57189f211fea9bfd47ae1688676f /src/libFLAC/metadata_iterators.c
parent9b8fdafe3a4ba0b6272bdcb0161f921bf750ca49 (diff)
downloadflac-5705b4d7b2c3c5311138e9f4b66658c51f3cc22b.tar.gz
Huge Windows utf8 I/O patch.
Patch from Janne Hyvärinen <cse@sci.fi>.
Diffstat (limited to 'src/libFLAC/metadata_iterators.c')
-rw-r--r--src/libFLAC/metadata_iterators.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c
index 7349ff80..5e1bf880 100644
--- a/src/libFLAC/metadata_iterators.c
+++ b/src/libFLAC/metadata_iterators.c
@@ -118,8 +118,8 @@ static FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path
static FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status);
static void cleanup_tempfile_(FILE **tempfile, char **tempfilename);
-static FLAC__bool get_file_stats_(const char *filename, struct stat *stats);
-static void set_file_stats_(const char *filename, struct stat *stats);
+static FLAC__bool get_file_stats_(const char *filename, struct _flac_stat *stats);
+static void set_file_stats_(const char *filename, struct _flac_stat *stats);
static int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence);
static FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle);
@@ -327,7 +327,7 @@ FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__Strea
struct FLAC__Metadata_SimpleIterator {
FILE *file;
char *filename, *tempfile_path_prefix;
- struct stat stats;
+ struct _flac_stat stats;
FLAC__bool has_stats;
FLAC__bool is_writable;
FLAC__Metadata_SimpleIteratorStatus status;
@@ -420,10 +420,10 @@ static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *it
FLAC__ASSERT(0 != iterator);
- if(read_only || 0 == (iterator->file = fopen(iterator->filename, "r+b"))) {
+ if(read_only || 0 == (iterator->file = flac_fopen(iterator->filename, "r+b"))) {
iterator->is_writable = false;
if(read_only || errno == EACCES) {
- if(0 == (iterator->file = fopen(iterator->filename, "rb"))) {
+ if(0 == (iterator->file = flac_fopen(iterator->filename, "rb"))) {
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
return false;
}
@@ -478,7 +478,7 @@ FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *it
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)
{
- const char *tempfile_path_prefix = 0; /*@@@ search for comments near 'rename(...)' for what it will take to finish implementing this */
+ const char *tempfile_path_prefix = 0; /*@@@ search for comments near 'flac_rename(...)' for what it will take to finish implementing this */
FLAC__ASSERT(0 != iterator);
FLAC__ASSERT(0 != filename);
@@ -1363,7 +1363,7 @@ static FLAC__bool chain_rewrite_metadata_in_place_(FLAC__Metadata_Chain *chain)
FLAC__ASSERT(0 != chain->filename);
- if(0 == (file = fopen(chain->filename, "r+b"))) {
+ if(0 == (file = flac_fopen(chain->filename, "r+b"))) {
chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
return false;
}
@@ -1388,7 +1388,7 @@ static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *t
FLAC__ASSERT(0 != chain->head);
/* copy the file prefix (data up to first metadata block */
- if(0 == (f = fopen(chain->filename, "rb"))) {
+ if(0 == (f = flac_fopen(chain->filename, "rb"))) {
chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
return false;
}
@@ -1526,7 +1526,7 @@ static FLAC__bool chain_read_(FLAC__Metadata_Chain *chain, const char *filename,
chain->is_ogg = is_ogg;
- if(0 == (file = fopen(filename, "rb"))) {
+ if(0 == (file = flac_fopen(filename, "rb"))) {
chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
return false;
}
@@ -1630,7 +1630,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata
FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats)
{
- struct stat stats;
+ struct _flac_stat stats;
const char *tempfile_path_prefix = 0;
FLAC__off_t current_length;
@@ -3243,7 +3243,7 @@ FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix
local_snprintf(*tempfilename, dest_len, "%s/%s%s", tempfile_path_prefix, p, tempfile_suffix);
}
- if(0 == (*tempfile = fopen(*tempfilename, "w+b"))) {
+ if(0 == (*tempfile = flac_fopen(*tempfilename, "w+b"))) {
*status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
return false;
}
@@ -3264,16 +3264,16 @@ FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tem
*tempfile = 0;
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ || defined __EMX__
- /* on some flavors of windows, rename() will fail if the destination already exists */
- if(unlink(filename) < 0) {
+ /* on some flavors of windows, flac_rename() will fail if the destination already exists */
+ if(flac_unlink(filename) < 0) {
cleanup_tempfile_(tempfile, tempfilename);
*status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR;
return false;
}
#endif
- /*@@@ to fully support the tempfile_path_prefix we need to update this piece to actually copy across filesystems instead of just rename(): */
- if(0 != rename(*tempfilename, filename)) {
+ /*@@@ to fully support the tempfile_path_prefix we need to update this piece to actually copy across filesystems instead of just flac_rename(): */
+ if(0 != flac_rename(*tempfilename, filename)) {
cleanup_tempfile_(tempfile, tempfilename);
*status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR;
return false;
@@ -3292,20 +3292,20 @@ void cleanup_tempfile_(FILE **tempfile, char **tempfilename)
}
if(0 != *tempfilename) {
- (void)unlink(*tempfilename);
+ (void)flac_unlink(*tempfilename);
free(*tempfilename);
*tempfilename = 0;
}
}
-FLAC__bool get_file_stats_(const char *filename, struct stat *stats)
+FLAC__bool get_file_stats_(const char *filename, struct _flac_stat *stats)
{
FLAC__ASSERT(0 != filename);
FLAC__ASSERT(0 != stats);
- return (0 == stat(filename, stats));
+ return (0 == flac_stat(filename, stats));
}
-void set_file_stats_(const char *filename, struct stat *stats)
+void set_file_stats_(const char *filename, struct _flac_stat *stats)
{
struct utimbuf srctime;
@@ -3314,8 +3314,8 @@ void set_file_stats_(const char *filename, struct stat *stats)
srctime.actime = stats->st_atime;
srctime.modtime = stats->st_mtime;
- (void)chmod(filename, stats->st_mode);
- (void)utime(filename, &srctime);
+ (void)flac_chmod(filename, stats->st_mode);
+ (void)flac_utime(filename, &srctime);
#if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__
FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));