Huge Windows utf8 I/O patch.

Patch from Janne Hyvärinen <cse@sci.fi>.
This commit is contained in:
Erik de Castro Lopo
2013-03-21 19:18:49 +11:00
parent 9b8fdafe3a
commit 5705b4d7b2
68 changed files with 3200 additions and 299 deletions

View File

@@ -379,7 +379,7 @@ bool FileDecoder::test_respond(bool is_ogg)
case LAYER_FILE:
{
printf("opening %sFLAC file... ", is_ogg? "Ogg ":"");
FILE *file = ::fopen(flacfilename(is_ogg), "rb");
FILE *file = ::flac_fopen(flacfilename(is_ogg), "rb");
if(0 == file) {
printf("ERROR (%s)\n", strerror(errno));
return false;
@@ -546,7 +546,7 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
case LAYER_STREAM:
case LAYER_SEEKABLE_STREAM:
printf("opening %sFLAC file... ", is_ogg? "Ogg ":"");
dynamic_cast<StreamDecoder*>(decoder)->file_ = ::fopen(flacfilename(is_ogg), "rb");
dynamic_cast<StreamDecoder*>(decoder)->file_ = ::flac_fopen(flacfilename(is_ogg), "rb");
if(0 == dynamic_cast<StreamDecoder*>(decoder)->file_) {
printf("ERROR (%s)\n", strerror(errno));
return false;
@@ -559,7 +559,7 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
case LAYER_FILE:
{
printf("opening FLAC file... ");
FILE *file = ::fopen(flacfilename(is_ogg), "rb");
FILE *file = ::flac_fopen(flacfilename(is_ogg), "rb");
if(0 == file) {
printf("ERROR (%s)\n", strerror(errno));
return false;

View File

@@ -310,7 +310,7 @@ static bool test_stream_encoder(Layer layer, bool is_ogg)
if(layer < LAYER_FILENAME) {
printf("opening file for FLAC output... ");
file = ::fopen(flacfilename(is_ogg), "w+b");
file = ::flac_fopen(flacfilename(is_ogg), "w+b");
if(0 == file) {
printf("ERROR (%s)\n", strerror(errno));
return false;

View File

@@ -208,7 +208,7 @@ bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename)
strcpy(*tempfilename, filename);
strcat(*tempfilename, tempfile_suffix);
if(0 == (*tempfile = fopen(*tempfilename, "wb")))
if(0 == (*tempfile = flac_fopen(*tempfilename, "wb")))
return false;
return true;
@@ -222,7 +222,7 @@ void cleanup_tempfile_(FILE **tempfile, char **tempfilename)
}
if(0 != *tempfilename) {
(void)unlink(*tempfilename);
(void)flac_unlink(*tempfilename);
free(*tempfilename);
*tempfilename = 0;
}
@@ -241,14 +241,14 @@ bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilen
}
#if defined _MSC_VER || 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);
return false;
}
#endif
if(0 != rename(*tempfilename, filename)) {
if(0 != flac_rename(*tempfilename, filename)) {
cleanup_tempfile_(tempfile, tempfilename);
return false;
}
@@ -258,14 +258,14 @@ bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilen
return true;
}
bool get_file_stats_(const char *filename, struct stat *stats)
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;
@@ -274,8 +274,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 __MINGW32__ && !defined __EMX__
FLAC_CHECK_RETURN(chown(filename, stats->st_uid, (gid_t)(-1)));
FLAC_CHECK_RETURN(chown(filename, (uid_t)(-1), stats->st_gid));
@@ -328,14 +328,14 @@ static bool write_chain_(FLAC::Metadata::Chain &chain, bool use_padding, bool pr
callbacks.eof = chain_eof_cb_;
if(chain.check_if_tempfile_needed(use_padding)) {
struct stat stats;
struct _flac_stat stats;
FILE *file, *tempfile;
char *tempfilename;
if(preserve_file_stats) {
if(!get_file_stats_(filename, &stats))
return false;
}
if(0 == (file = fopen(filename, "rb")))
if(0 == (file = flac_fopen(filename, "rb")))
return false; /*@@@@ chain status still says OK though */
if(!open_tempfile_(filename, &tempfile, &tempfilename)) {
fclose(file);
@@ -356,7 +356,7 @@ static bool write_chain_(FLAC::Metadata::Chain &chain, bool use_padding, bool pr
set_file_stats_(filename, &stats);
}
else {
FILE *file = fopen(filename, "r+b");
FILE *file = flac_fopen(filename, "r+b");
if(0 == file)
return false; /*@@@@ chain status still says OK though */
if(!chain.write(use_padding, (::FLAC__IOHandle)file, callbacks)) {
@@ -384,7 +384,7 @@ static bool read_chain_(FLAC::Metadata::Chain &chain, const char *filename, bool
{
bool ret;
FILE *file = fopen(filename, "rb");
FILE *file = flac_fopen(filename, "rb");
if(0 == file)
return false; /*@@@@ chain status still says OK though */
ret = chain.read((::FLAC__IOHandle)file, callbacks, is_ogg);
@@ -2077,7 +2077,7 @@ static bool test_level_2_misc_(bool is_ogg)
printf("read chain (callback-based)\n");
{
FILE *file = fopen(flacfilename(is_ogg), "rb");
FILE *file = flac_fopen(flacfilename(is_ogg), "rb");
if(0 == file)
return die_("opening file");
if(!chain.read((::FLAC__IOHandle)file, callbacks)) {
@@ -2098,7 +2098,7 @@ static bool test_level_2_misc_(bool is_ogg)
printf("read chain (callback-based)\n");
{
FILE *file = fopen(flacfilename(is_ogg), "rb");
FILE *file = flac_fopen(flacfilename(is_ogg), "rb");
if(0 == file)
return die_("opening file");
if(!chain.read((::FLAC__IOHandle)file, callbacks)) {
@@ -2126,7 +2126,7 @@ static bool test_level_2_misc_(bool is_ogg)
printf("read chain (callback-based)\n");
{
FILE *file = fopen(flacfilename(is_ogg), "rb");
FILE *file = flac_fopen(flacfilename(is_ogg), "rb");
if(0 == file)
return die_("opening file");
if(!chain.read((::FLAC__IOHandle)file, callbacks)) {

View File

@@ -170,6 +170,86 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (UTF8)|Win32"
OutputDirectory="..\..\objs\release\bin"
IntermediateDirectory="Release"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;FLAC__NO_DLL;FLAC__STRINGS_IN_UTF8"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4267;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\objs\release\lib\libogg_static.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="uuid.lib"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>