Tested in 3 majors OS'es... no problems... closes #681
This commit is contained in:
parent
8e70d4dfa2
commit
957ee4a47e
|
@ -1125,19 +1125,26 @@ int TIDY_CALL tidyParseSource( TidyDoc tdoc, TidyInputSource* source )
|
||||||
return tidyDocParseSource( doc, source );
|
return tidyDocParseSource( doc, source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define M_IS_DIR _S_IFDIR
|
||||||
|
#else // !WIN32
|
||||||
|
#define M_IS_DIR S_IFDIR
|
||||||
|
#endif
|
||||||
int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
||||||
{
|
{
|
||||||
int status = -ENOENT;
|
int status = -ENOENT;
|
||||||
FILE* fin = fopen( filnam, "r+" );
|
FILE* fin = 0;
|
||||||
|
struct stat sbuf = { 0 }; /* Is. #681 - read-only files */
|
||||||
if ( !fin )
|
if ( stat(filnam,&sbuf) != 0 )
|
||||||
|
{
|
||||||
|
TY_(ReportFileError)( doc, filnam, FILE_NOT_FILE );
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
if (sbuf.st_mode & M_IS_DIR) /* and /NOT/ if a DIRECTORY */
|
||||||
{
|
{
|
||||||
TY_(ReportFileError)(doc, filnam, FILE_NOT_FILE);
|
TY_(ReportFileError)(doc, filnam, FILE_NOT_FILE);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( fin );
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return TY_(DocParseFileWithMappedFile)( doc, filnam );
|
return TY_(DocParseFileWithMappedFile)( doc, filnam );
|
||||||
|
@ -1147,7 +1154,6 @@ int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
||||||
|
|
||||||
#if PRESERVE_FILE_TIMES
|
#if PRESERVE_FILE_TIMES
|
||||||
{
|
{
|
||||||
struct stat sbuf = { 0 };
|
|
||||||
/* get last modified time */
|
/* get last modified time */
|
||||||
TidyClearMemory(&doc->filetimes, sizeof(doc->filetimes));
|
TidyClearMemory(&doc->filetimes, sizeof(doc->filetimes));
|
||||||
if (fin && cfgBool(doc, TidyKeepFileTimes) &&
|
if (fin && cfgBool(doc, TidyKeepFileTimes) &&
|
||||||
|
|
Loading…
Reference in a new issue