The implementation of [NSFileManager fileSystemAttributesAtPath:] is not
able to determine the size of very large volumes. My partition is about 17GB
with 14GB free and the result was 2MB(!) total and 15(GB) free.
The problem can be solved very easily:
1. use 'unsigned long long' instead of 'long long'
2. cast the DWORDs (longs) to 'unsigned long long' for the calculation
Then it looks like this:
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path
{
#if defined(__MINGW__)
! unsigned long long totalsize, freesize;
id values[5];
id keys[5] = {
NSFileSystemSize,
NSFileSystemFreeSize,
NSFileSystemNodes,
NSFileSystemFreeNodes,
NSFileSystemNumber
};
DWORD SectorsPerCluster, BytesPerSector, NumberFreeClusters;
DWORD TotalNumberClusters;
const char *cpath = [self fileSystemRepresentationWithPath: path];
if (!GetDiskFreeSpace(cpath, &SectorsPerCluster,
&BytesPerSector, &NumberFreeClusters, &TotalNumberClusters))
return nil;
! totalsize = (unsigned long long)TotalNumberClusters *
(unsigned long long)SectorsPerCluster *
(unsigned long long)BytesPerSector;
! freesize = (unsigned long long)NumberFreeClusters *
(unsigned long long)SectorsPerCluster *
(unsigned long long)BytesPerSector;
! values[0] = [NSNumber numberWithUnsignedLongLong: totalsize];
! values[1] = [NSNumber numberWithUnsignedLongLong: freesize];
values[2] = [NSNumber numberWithLong: LONG_MAX];
values[3] = [NSNumber numberWithLong: LONG_MAX];
values[4] = [NSNumber numberWithUnsignedInt: 0];
return [NSDictionary dictionaryWithObjects: values forKeys: keys count:
5];
#else
.
.
.
Michael
_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep