Solution of fileExists support for > 2Gb files from Ken Sewell, applied by Robert Osfield.

This commit is contained in:
Robert Osfield 2004-10-03 08:50:56 +00:00
parent e4167d9baa
commit 60cb89486f

View File

@ -62,8 +62,8 @@ bool osgDB::makeDirectory( const std::string &path )
return false;
}
struct stat stbuf;
if( stat( path.c_str(), &stbuf ) == 0 )
struct stat64 stbuf;
if( stat64( path.c_str(), &stbuf ) == 0 )
{
if( S_ISDIR(stbuf.st_mode))
return true;
@ -82,7 +82,7 @@ bool osgDB::makeDirectory( const std::string &path )
if( dir.empty() )
break;
if( stat( dir.c_str(), &stbuf ) < 0 )
if( stat64( dir.c_str(), &stbuf ) < 0 )
{
switch( errno )
{
@ -148,11 +148,8 @@ bool osgDB::fileExists(const std::string& filename)
osgDB::FileType osgDB::fileType(const std::string& filename)
{
#if 1
// proposed single code path, from Bruce Clay.
struct stat fileStat;
if ( stat(filename.c_str(), &fileStat) != 0 )
struct stat64 fileStat;
if ( stat64(filename.c_str(), &fileStat) != 0 )
{
return FILE_NOT_FOUND;
} // end if
@ -163,43 +160,6 @@ osgDB::FileType osgDB::fileType(const std::string& filename)
return REGULAR_FILE;
return FILE_NOT_FOUND;
#else
#if defined(WIN32) && !defined(__CYGWIN__)
struct _stat fileStat;
if ( _stat(filename.c_str(), &fileStat) != 0 )
{
return FILE_NOT_FOUND;
} // end if
if ( fileStat.st_mode & _S_IFDIR )
return DIRECTORY;
else if ( fileStat.st_mode & _S_IFREG )
return REGULAR_FILE;
return FILE_NOT_FOUND;
#else
struct stat fileStat;
if(stat(filename.c_str(), &fileStat) == -1)
{
return FILE_NOT_FOUND;
}
if(S_ISREG(fileStat.st_mode))
{
return REGULAR_FILE;
}
if(S_ISDIR(fileStat.st_mode))
{
return DIRECTORY;
}
return FILE_NOT_FOUND;
#endif
#endif
}
std::string osgDB::findFileInPath(const std::string& filename, const FilePathList& filepath,CaseSensitivity caseSensitivity)