Set _LARGEFILE_SOURCE; use O_NONBLOCK where available, in case of file-to-fifo switch or mandatory file locking
This commit is contained in:
parent
4af1a707ef
commit
c41aba17db
|
@ -3251,8 +3251,8 @@ ac_config_headers="$ac_config_headers config.h"
|
||||||
rm -f src/tripwire/syslog.h 2> /dev/null
|
rm -f src/tripwire/syslog.h 2> /dev/null
|
||||||
chmod 755 install-sh 2> /dev/null
|
chmod 755 install-sh 2> /dev/null
|
||||||
|
|
||||||
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
|
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor -D_LARGEFILE_SOURCE"}
|
||||||
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
|
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor -D_LARGEFILE_SOURCE"}
|
||||||
|
|
||||||
# Check whether --enable-static was given.
|
# Check whether --enable-static was given.
|
||||||
if test "${enable_static+set}" = set; then :
|
if test "${enable_static+set}" = set; then :
|
||||||
|
|
|
@ -17,8 +17,8 @@ chmod 755 install-sh 2> /dev/null
|
||||||
dnl ###############
|
dnl ###############
|
||||||
dnl Setup defaults
|
dnl Setup defaults
|
||||||
dnl ###############
|
dnl ###############
|
||||||
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
|
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor -D_LARGEFILE_SOURCE"}
|
||||||
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
|
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor -D_LARGEFILE_SOURCE"}
|
||||||
|
|
||||||
dnl #####################
|
dnl #####################
|
||||||
dnl Configuration options
|
dnl Configuration options
|
||||||
|
|
|
@ -678,6 +678,7 @@ void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
|
||||||
uint32 flags = cFile::OPEN_READ;
|
uint32 flags = cFile::OPEN_READ;
|
||||||
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
||||||
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
||||||
|
flags |= ( ( openFlags & FA_NONBLOCKING ) ? cFile::OPEN_NONBLOCKING :0 );
|
||||||
|
|
||||||
mCurrentFilename = filename;
|
mCurrentFilename = filename;
|
||||||
mCurrentFile.Open( filename, flags );
|
mCurrentFile.Open( filename, flags );
|
||||||
|
@ -703,6 +704,7 @@ void cFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
|
||||||
uint32 flags = cFile::OPEN_WRITE;
|
uint32 flags = cFile::OPEN_WRITE;
|
||||||
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
||||||
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
||||||
|
flags |= ( ( openFlags & FA_NONBLOCKING ) ? cFile::OPEN_NONBLOCKING :0 );
|
||||||
|
|
||||||
mCurrentFilename = filename;
|
mCurrentFilename = filename;
|
||||||
mCurrentFile.Open( filename, flags );
|
mCurrentFile.Open( filename, flags );
|
||||||
|
|
|
@ -259,7 +259,8 @@ public:
|
||||||
enum OpenFlags
|
enum OpenFlags
|
||||||
{
|
{
|
||||||
FA_OPEN_TEXT = 0x1,
|
FA_OPEN_TEXT = 0x1,
|
||||||
FA_OPEN_TRUNCATE = 0x2
|
FA_OPEN_TRUNCATE = 0x2,
|
||||||
|
FA_NONBLOCKING = 0x4
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Open should throw
|
// TODO: Open should throw
|
||||||
|
|
|
@ -89,14 +89,14 @@ public:
|
||||||
enum OpenFlags
|
enum OpenFlags
|
||||||
{
|
{
|
||||||
// note that reading from the file is implicit
|
// note that reading from the file is implicit
|
||||||
//
|
|
||||||
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
|
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
|
||||||
OPEN_WRITE = 0x00000002, // we will be writing to the file
|
OPEN_WRITE = 0x00000002, // we will be writing to the file
|
||||||
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
|
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
|
||||||
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
||||||
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
|
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
|
||||||
OPEN_TEXT = 0x00000020,
|
OPEN_TEXT = 0x00000020,
|
||||||
OPEN_EXCLUSIVE = 0x00000040 // Use O_CREAT | O_EXCL
|
OPEN_EXCLUSIVE = 0x00000040, // Use O_CREAT | O_EXCL
|
||||||
|
OPEN_NONBLOCKING = 0x00000080, // Use non-blocking i/o [Unix]
|
||||||
};
|
};
|
||||||
|
|
||||||
//Ctor, Dtor, CpyCtor, Operator=:
|
//Ctor, Dtor, CpyCtor, Operator=:
|
||||||
|
|
|
@ -168,7 +168,10 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
if ( flags & OPEN_CREATE )
|
if ( flags & OPEN_CREATE )
|
||||||
perm |= O_CREAT;
|
perm |= O_CREAT;
|
||||||
|
|
||||||
|
#ifdef O_NONBLOCK
|
||||||
|
if( flags & OPEN_NONBLOCKING )
|
||||||
|
perm |= O_NONBLOCK;
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
// actually open the file
|
// actually open the file
|
||||||
//
|
//
|
||||||
|
|
|
@ -295,7 +295,7 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj)
|
||||||
pTheArch = &arch;
|
pTheArch = &arch;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
arch.OpenRead(strName.c_str());
|
arch.OpenRead(strName.c_str(), cFileArchive::FA_NONBLOCKING);
|
||||||
}
|
}
|
||||||
catch (eArchive&)
|
catch (eArchive&)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue