KWSys 2015-08-03 (dad68c33)
Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ dad68c33 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' f63febb7..dad68c33 James Johnston (1): dad68c33 Encoding: Fix undefined behavior if out of memory. Jean-Christophe Fillion-Robin (2): e5c23738 SystemTools: Fix DetectFileType failure on missing file 6d83c113 SystemTools: Fix DetectFileType failure on directory Sebastian Schuberth (1): 4db8e69f SystemTools: Implement FileIsSymlink on Windows
This commit is contained in:
parent
1feafc643b
commit
9a59ae5c19
14
EncodingC.c
14
EncodingC.c
|
@ -45,8 +45,11 @@ wchar_t* kwsysEncoding_DupToWide(const char* str)
|
||||||
if(length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
ret = (wchar_t*)malloc((length)*sizeof(wchar_t));
|
ret = (wchar_t*)malloc((length)*sizeof(wchar_t));
|
||||||
ret[0] = 0;
|
if(ret)
|
||||||
kwsysEncoding_mbstowcs(ret, str, length);
|
{
|
||||||
|
ret[0] = 0;
|
||||||
|
kwsysEncoding_mbstowcs(ret, str, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +75,11 @@ char* kwsysEncoding_DupToNarrow(const wchar_t* str)
|
||||||
if(length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
ret = (char*)malloc(length);
|
ret = (char*)malloc(length);
|
||||||
ret[0] = 0;
|
if(ret)
|
||||||
kwsysEncoding_wcstombs(ret, str, length);
|
{
|
||||||
|
ret[0] = 0;
|
||||||
|
kwsysEncoding_wcstombs(ret, str, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3198,8 +3198,16 @@ bool SystemTools::FileIsDirectory(const kwsys_stl::string& inName)
|
||||||
bool SystemTools::FileIsSymlink(const kwsys_stl::string& name)
|
bool SystemTools::FileIsSymlink(const kwsys_stl::string& name)
|
||||||
{
|
{
|
||||||
#if defined( _WIN32 )
|
#if defined( _WIN32 )
|
||||||
(void)name;
|
DWORD attr = GetFileAttributesW(
|
||||||
return false;
|
SystemTools::ConvertToWindowsExtendedPath(name).c_str());
|
||||||
|
if (attr != INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
struct stat fs;
|
struct stat fs;
|
||||||
if(lstat(name.c_str(), &fs) == 0)
|
if(lstat(name.c_str(), &fs) == 0)
|
||||||
|
@ -4230,6 +4238,11 @@ SystemTools::DetectFileType(const char *filename,
|
||||||
return SystemTools::FileTypeUnknown;
|
return SystemTools::FileTypeUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SystemTools::FileIsDirectory(filename))
|
||||||
|
{
|
||||||
|
return SystemTools::FileTypeUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *fp = Fopen(filename, "rb");
|
FILE *fp = Fopen(filename, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
|
@ -4243,6 +4256,7 @@ SystemTools::DetectFileType(const char *filename,
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (read_length == 0)
|
if (read_length == 0)
|
||||||
{
|
{
|
||||||
|
delete [] buffer;
|
||||||
return SystemTools::FileTypeUnknown;
|
return SystemTools::FileTypeUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,10 @@ static bool CheckEscapeChars(kwsys_stl::string input,
|
||||||
static bool CheckFileOperations()
|
static bool CheckFileOperations()
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
const kwsys_stl::string testNonExistingFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
||||||
|
"/testSystemToolsNonExistingFile");
|
||||||
|
const kwsys_stl::string testDotFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
||||||
|
"/.");
|
||||||
const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
||||||
"/testSystemTools.bin");
|
"/testSystemTools.bin");
|
||||||
const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR
|
||||||
|
@ -106,6 +110,24 @@ static bool CheckFileOperations()
|
||||||
"/testSystemToolsNewDir");
|
"/testSystemToolsNewDir");
|
||||||
const kwsys_stl::string testNewFile(testNewDir + "/testNewFile.txt");
|
const kwsys_stl::string testNewFile(testNewDir + "/testNewFile.txt");
|
||||||
|
|
||||||
|
if (kwsys::SystemTools::DetectFileType(testNonExistingFile.c_str()) !=
|
||||||
|
kwsys::SystemTools::FileTypeUnknown)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr
|
||||||
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
|
<< testNonExistingFile << kwsys_ios::endl;
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kwsys::SystemTools::DetectFileType(testDotFile.c_str()) !=
|
||||||
|
kwsys::SystemTools::FileTypeUnknown)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr
|
||||||
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
|
<< testDotFile << kwsys_ios::endl;
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) !=
|
if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) !=
|
||||||
kwsys::SystemTools::FileTypeBinary)
|
kwsys::SystemTools::FileTypeBinary)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue