Author: rfm
Date: Fri Jul 25 12:38:20 2014
New Revision: 38010
URL: http://svn.gna.org/viewcvs/gnustep?rev=38010&view=rev
Log:
Add Yavor's lfs patch
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/GSFileHandle.m
libs/base/trunk/Source/NSData.m
libs/base/trunk/Source/NSFileManager.m
libs/base/trunk/Source/win32/GSFileHandle.m
libs/base/trunk/configure.ac
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Fri Jul 25 12:38:20 2014
@@ -1,3 +1,15 @@
+2014-07-13 Yavor Doganov <[email protected]>
+
+ Add large file support (LFS) for NSData.
+ * configure.ac: Call AC_FUNC_FSEEKO/AC_SYS_LARGEFILE.
+ * Source/NSData.m (readContentsOfFile): Use fseeko/ftello and
+ off_t as appropriate.
+ (-initWithContentsOfFile:): Define fileLength of type off_t.
+ * Source/GSFileHandle.m:
+ * Source/win32/GSFileHandle.m:
+ * Source/NSFileManager.m: Remove _FILE_OFFSET_BITS define (now
+ defined globally in config.h).
+
2014-07-14 Richard Frith-Macdonald <[email protected]>
* Source/NSRunLoop.m: ([-runMode:beforeDate:]) check performers as
Modified: libs/base/trunk/Source/GSFileHandle.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSFileHandle.m?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/Source/GSFileHandle.m (original)
+++ libs/base/trunk/Source/GSFileHandle.m Fri Jul 25 12:38:20 2014
@@ -21,8 +21,6 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
-
-#define _FILE_OFFSET_BITS 64
#import "common.h"
#define EXPOSE_NSFileHandle_IVARS 1
Modified: libs/base/trunk/Source/NSData.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSData.m?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/Source/NSData.m (original)
+++ libs/base/trunk/Source/NSData.m Fri Jul 25 12:38:20 2014
@@ -140,7 +140,7 @@
static IMP appendImp;
static BOOL
-readContentsOfFile(NSString* path, void** buf, long* len, NSZone* zone)
+readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
{
#if defined(__MINGW__)
const unichar *thePath = 0;
@@ -150,7 +150,7 @@
FILE *theFile = 0;
void *tmp = 0;
int c;
- long fileLength;
+ off_t fileLength;
#if defined(__MINGW__)
thePath = (const unichar*)[path fileSystemRepresentation];
@@ -175,14 +175,10 @@
goto failure;
}
- // FIXME: since fseek returns a long, this code will fail on files
- // larger than ~2GB on 32-bit systems. Probably this entire function should
- // be removed and NSFileHandle used instead. -Eric
-
/*
* Seek to the end of the file.
*/
- c = fseek(theFile, 0L, SEEK_END);
+ c = fseeko(theFile, 0, SEEK_END);
if (c != 0)
{
NSWarnFLog(@"Seek to end of file (%@) failed - %@", path,
@@ -192,10 +188,10 @@
/*
* Determine the length of the file (having seeked to the end of the
- * file) by calling ftell().
+ * file) by calling ftello().
*/
- fileLength = ftell(theFile);
- if (fileLength == -1)
+ fileLength = ftello(theFile);
+ if (fileLength == (off_t) -1)
{
NSWarnFLog(@"Ftell on %@ failed - %@", path, [NSError _last]);
goto failure;
@@ -205,7 +201,7 @@
* Rewind the file pointer to the beginning, preparing to read in
* the file.
*/
- c = fseek(theFile, 0L, SEEK_SET);
+ c = fseeko(theFile, 0, SEEK_SET);
if (c != 0)
{
NSWarnFLog(@"Fseek to start of file (%@) failed - %@", path,
@@ -246,8 +242,8 @@
#endif
if (tmp == 0)
{
- NSLog(@"Malloc failed for file (%@) of length %ld - %@", path,
- fileLength + c, [NSError _last]);
+ NSLog(@"Malloc failed for file (%@) of length %jd - %@", path,
+ (intmax_t)fileLength + c, [NSError _last]);
goto failure;
}
memcpy(tmp + fileLength, buf, c);
@@ -256,7 +252,7 @@
}
else
{
- long offset = 0;
+ off_t offset = 0;
#if GS_WITH_GC
tmp = NSAllocateCollectable(fileLength, 0);
@@ -265,8 +261,8 @@
#endif
if (tmp == 0)
{
- NSLog(@"Malloc failed for file (%@) of length %ld - %@", path,
- fileLength, [NSError _last]);
+ NSLog(@"Malloc failed for file (%@) of length %jd - %@", path,
+ (intmax_t)fileLength, [NSError _last]);
goto failure;
}
@@ -632,7 +628,7 @@
- (id) initWithContentsOfFile: (NSString*)path
{
void *fileBytes;
- long fileLength;
+ off_t fileLength;
#if GS_WITH_GC
if (readContentsOfFile(path, &fileBytes, &fileLength, 0) == NO)
@@ -647,7 +643,7 @@
}
#endif
self = [self initWithBytesNoCopy: fileBytes
- length: fileLength
+ length: (NSUInteger)fileLength
freeWhenDone: YES];
return self;
}
Modified: libs/base/trunk/Source/NSFileManager.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSFileManager.m?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/Source/NSFileManager.m (original)
+++ libs/base/trunk/Source/NSFileManager.m Fri Jul 25 12:38:20 2014
@@ -37,7 +37,6 @@
$Date$ $Revision$
*/
-#define _FILE_OFFSET_BITS 64
/* The following define is needed for Solaris get(pw/gr)(nam/uid)_r declartions
which default to pre POSIX declaration. */
#define _POSIX_PTHREAD_SEMANTICS
Modified: libs/base/trunk/Source/win32/GSFileHandle.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/win32/GSFileHandle.m?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/Source/win32/GSFileHandle.m (original)
+++ libs/base/trunk/Source/win32/GSFileHandle.m Fri Jul 25 12:38:20 2014
@@ -21,8 +21,6 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
-
-#define _FILE_OFFSET_BITS 64
#include "common.h"
Modified: libs/base/trunk/configure.ac
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/configure.ac?rev=38010&r1=38009&r2=38010&view=diff
==============================================================================
--- libs/base/trunk/configure.ac (original)
+++ libs/base/trunk/configure.ac Fri Jul 25 12:38:20 2014
@@ -1067,6 +1067,21 @@
exit 1
fi
+# Large file support needed by NSData/NSFileHandle.
+# These macros must be called after AC_USE_SYSTEM_EXTENSIONS because
+# the `fseeko' declaration may be hidden by default on some systems.
+AC_FUNC_FSEEKO
+AH_BOTTOM([
+/* Define `fseeko' to `fseek' if the former is missing.
+ Likewise for `ftello'. */
+#if !HAVE_FSEEKO
+# define fseeko fseek
+# define ftello ftell
+#endif
+])
+AC_SYS_LARGEFILE
+AC_TYPE_OFF_T
+
#--------------------------------------------------------------------
# Check wether the compiler supports UTF-8 constant strings
#--------------------------------------------------------------------
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs