From e2f9031da6120f5e8f220255076f8bf3cbd2805f Mon Sep 17 00:00:00 2001 From: Fons Rademakers <Fons.Rademakers@cern.ch> Date: Wed, 28 Jan 2004 02:41:42 +0000 Subject: [PATCH] add GetPathInfo() with Long_t size for backward compatability. This call will print an Error in case the file is larger than 2 GB and the machine has a long of 4 bytes. git-svn-id: http://root.cern.ch/svn/root/trunk@8061 27541ba8-7e3a-0410-8455-c3a389f83636 --- base/inc/TSystem.h | 3 ++- base/src/TSystem.cxx | 32 +++++++++++++++++++++++++------- rint/src/TTabCom.cxx | 4 ++-- unix/inc/TUnixSystem.h | 5 ++++- winnt/inc/TWinNTSystem.h | 5 ++++- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/base/inc/TSystem.h b/base/inc/TSystem.h index 05f030de031..de83a077273 100644 --- a/base/inc/TSystem.h +++ b/base/inc/TSystem.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TSystem.h,v 1.34 2004/01/24 23:07:47 brun Exp $ +// @(#)root/base:$Name: $:$Id: TSystem.h,v 1.35 2004/01/25 17:59:53 rdm Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -269,6 +269,7 @@ public: virtual int Link(const char *from, const char *to); virtual int Symlink(const char *from, const char *to); virtual int Unlink(const char *name); + int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime); virtual int GetPathInfo(const char *path, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime); virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree); virtual int Umask(Int_t mask); diff --git a/base/src/TSystem.cxx b/base/src/TSystem.cxx index 58a02a89136..0b9c8a8264e 100644 --- a/base/src/TSystem.cxx +++ b/base/src/TSystem.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TSystem.cxx,v 1.79 2004/01/24 23:07:47 brun Exp $ +// @(#)root/base:$Name: $:$Id: TSystem.cxx,v 1.80 2004/01/25 17:59:54 rdm Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -917,7 +917,25 @@ int TSystem::Unlink(const char *) } //______________________________________________________________________________ -int TSystem::GetPathInfo(const char*, Long_t*, Long64_t*, Long_t*, Long_t*) +int TSystem::GetPathInfo(const char *path, Long_t *id, Long_t *size, + Long_t *flags, Long_t *modtime) +{ + // Get info about a file: id, size, flags, modification time. + + Long64_t lsize; + + int res = GetPathInfo(path, id, &lsize, flags, modtime); + + if (size && sizeof(Long_t) == 4 && lsize > kMaxInt) { + Error("GetPathInfo", "file %s > 2 GB, use GetPathInfo() with Long64_t size", path); + *size = kMaxInt; + } + + return res; +} + +//______________________________________________________________________________ +int TSystem::GetPathInfo(const char *, Long_t *, Long64_t *, Long_t *, Long_t *) { // Get info about a file: id, size, flags, modification time. @@ -926,7 +944,7 @@ int TSystem::GetPathInfo(const char*, Long_t*, Long64_t*, Long_t*, Long_t*) } //______________________________________________________________________________ -int TSystem::GetFsInfo(const char*, Long_t*, Long_t*, Long_t*, Long_t*) +int TSystem::GetFsInfo(const char *, Long_t *, Long_t *, Long_t *, Long_t *) { // Get info about a file system: fs type, block size, number of blocks, // number of free blocks. @@ -1748,9 +1766,9 @@ int TSystem::CompileMacro(const char *filename, Option_t * opt, AssignAndDelete( stderrfile, ConcatFileName(build_loc,"stderr.tmp") ); #endif - if ( (gSystem->GetPathInfo( library, 0, 0, 0, &lib_time ) != 0) + if ( (gSystem->GetPathInfo( library, 0, (Long_t*)0, 0, &lib_time ) != 0) || - (gSystem->GetPathInfo( filename, 0, 0, 0, &file_time ) == 0 + (gSystem->GetPathInfo( filename, 0, (Long_t*)0, 0, &file_time ) == 0 && ( lib_time < file_time ) ) ) { // the library does not exist and is older than the script. @@ -1762,7 +1780,7 @@ int TSystem::CompileMacro(const char *filename, Option_t * opt, // does not exist we regenerate it Bool_t needDependencies; - if ( gSystem->GetPathInfo( depfilename, 0, 0, 0, &file_time ) == 0 ) { + if ( gSystem->GetPathInfo( depfilename, 0,(Long_t*) 0, 0, &file_time ) == 0 ) { needDependencies = ( file_time < lib_time ); } else { needDependencies = true; @@ -1839,7 +1857,7 @@ int TSystem::CompileMacro(const char *filename, Option_t * opt, line[current] = 0; Long_t filetime; - if ( gSystem->GetPathInfo( line, 0, 0, 0, &filetime ) == 0 ) { + if ( gSystem->GetPathInfo( line, 0, (Long_t*)0, 0, &filetime ) == 0 ) { modified |= ( lib_time <= filetime ); } } diff --git a/rint/src/TTabCom.cxx b/rint/src/TTabCom.cxx index cab6426f2ba..e8616a97d3c 100644 --- a/rint/src/TTabCom.cxx +++ b/rint/src/TTabCom.cxx @@ -1,4 +1,4 @@ -// @(#)root/rint:$Name: $:$Id: TTabCom.cxx,v 1.18 2003/06/05 14:22:51 rdm Exp $ +// @(#)root/rint:$Name: $:$Id: TTabCom.cxx,v 1.19 2003/06/06 09:09:42 brun Exp $ // Author: Christian Lacunza <lacunza@cdfsg6.lbl.gov> 27/04/99 // Modified by Artur Szostak <artur@alice.phy.uct.ac.za> : 1 June 2003 @@ -1027,7 +1027,7 @@ Bool_t TTabCom::IsDirectory(const char fileName[]) /////////////////////////////////////////////////////// Long_t flags = 0; - gSystem->GetPathInfo(fileName, 0, 0, &flags, 0); + gSystem->GetPathInfo(fileName, 0, (Long_t*)0, &flags, 0); return (int) flags & 2; } TSeqCol *TTabCom::NewListOfFilesInPath(const char path1[]) diff --git a/unix/inc/TUnixSystem.h b/unix/inc/TUnixSystem.h index 5b4e58f2649..3b6844e208e 100644 --- a/unix/inc/TUnixSystem.h +++ b/unix/inc/TUnixSystem.h @@ -1,4 +1,4 @@ -// @(#)root/unix:$Name: $:$Id: TUnixSystem.h,v 1.14 2003/12/01 07:15:26 rdm Exp $ +// @(#)root/unix:$Name: $:$Id: TUnixSystem.h,v 1.15 2003/12/30 13:16:51 brun Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -144,6 +144,9 @@ public: int Link(const char *from, const char *to); int Symlink(const char *from, const char *to); int Unlink(const char *name); + int GetPathInfo(const char *path, Long_t *id, Long_t *size, + Long_t *flags, Long_t *modtime) + { return TSystem::GetPathInfo(path, id, size, flags, modtime); } int GetPathInfo(const char *path, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime); int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, diff --git a/winnt/inc/TWinNTSystem.h b/winnt/inc/TWinNTSystem.h index ca2a4f47543..e32b1cf6a25 100644 --- a/winnt/inc/TWinNTSystem.h +++ b/winnt/inc/TWinNTSystem.h @@ -1,4 +1,4 @@ -// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.h,v 1.23 2004/01/25 15:48:49 brun Exp $ +// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.h,v 1.24 2004/01/26 09:49:26 brun Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -127,6 +127,9 @@ public: int Link(const char *from, const char *to); int Unlink(const char *name); int SetNonBlock(int fd); + int GetPathInfo(const char *path, Long_t *id, Long_t *size, + Long_t *flags, Long_t *modtime) + { return TSystem::GetPathInfo(path, id, size, flags, modtime); } int GetPathInfo(const char *path, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime); int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, -- GitLab