From 60cb89486fc2b5334794aee6abab500264fee6ba Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 3 Oct 2004 08:50:56 +0000 Subject: [PATCH] Solution of fileExists support for > 2Gb files from Ken Sewell, applied by Robert Osfield. --- src/osgDB/FileUtils.cpp | 50 +++++------------------------------------ 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/src/osgDB/FileUtils.cpp b/src/osgDB/FileUtils.cpp index 421838cf5..e684462a7 100644 --- a/src/osgDB/FileUtils.cpp +++ b/src/osgDB/FileUtils.cpp @@ -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)