• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSFileSize only returns nil or "6148"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileSize only returns nil or "6148"


  • Subject: Re: NSFileSize only returns nil or "6148"
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 24 Jul 2002 14:49:22 +0200

On Wednesday, July 24, 2002, at 05:11 , Jaime Magiera wrote:

Here's the code. Can anyone spot a problem? Thanks.

NSMutableDictionary *dict = [thePrefManager loadPreferences];
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager]
enumeratorAtPath:[dict objectForKey:@"uploadsFolderPath"]];
while (pname = [direnum nextObject]) {
NSDictionary *fileAttributes = [theManager fileAttributesAtPath:pname traverseLink:false];
CFShow(pname);
if (fsize = [fileAttributes objectForKey:NSFileSize])
CFShow(fsize);
}

Evidently, the CFShow of yours is to be blamed:

107 /tmp> cat q.m
#import <Foundation/Foundation.h>
int main() {
id p=[NSAutoreleasePool new];
id theManager=[NSFileManager defaultManager];
NSDirectoryEnumerator *direnum=[theManager enumeratorAtPath:@"/tmp"];
while (p=[direnum nextObject]) {
NSDictionary *fileAttributes=[theManager fileAttributesAtPath:p traverseLink:NO];
// !!! the proper BOOL values are YES/NO !!!
id fsize;

if (fsize=[fileAttributes objectForKey:NSFileSize])
NSLog(@"path %@, size %@",p,fsize);
}
return 0;
}
108 /tmp> cc -framework Foundation q.m && ./a.out
2002-07-24 14:47:15.335 a.out[5752] path a.out, size 17980
2002-07-24 14:47:15.339 a.out[5752] path ocs, size 58
2002-07-24 14:47:15.342 a.out[5752] path ocs/mail, size 24
2002-07-24 14:47:15.343 a.out[5752] path q.m, size 473
2002-07-24 14:47:15.346 a.out[5752] path slp_ipc, size 0
2002-07-24 14:47:15.348 a.out[5752] path video.txt, size 51758
109 /tmp> ls -l
total 152
-rwxr-xr-x 1 ocs wheel 17980 Jul 24 14:47 a.out*
drwxr-xr-x 3 ocs wheel 58 Jul 19 00:14 ocs/
-rw-r--r-- 1 ocs wheel 473 Jul 24 14:45 q.m
srwxrw-rw- 1 root wheel 0 Jul 17 12:14 slp_ipc=
-rw-r--r-- 1 ocs wheel 51758 Jul 22 23:21 video.txt
110 /tmp>

---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSFileSize only returns nil or "6148" (From: Jaime Magiera <email@hidden>)

  • Prev by Date: Re: How to find icon file path?
  • Next by Date: Re: question on disclosure triangle
  • Previous by thread: NSFileSize only returns nil or "6148"
  • Next by thread: Programmatic mount of AFP volumes?
  • Index(es):
    • Date
    • Thread