How do I obtain read access to a file that I'm not allowed access?
How do I obtain read access to a file that I'm not allowed access?
- Subject: How do I obtain read access to a file that I'm not allowed access?
- From: "Alan Smith" <email@hidden>
- Date: Sat, 5 Aug 2006 22:03:20 -0400
Disclaimer: I know some of this is not specific to Cocoa but I do know
that you people will be able to help me. I'm not on the Carbon-dev
list (if there still is one) and was hesitant to join it for just this
one question because I don't know if it is still active. I hope this
is an askable question here and that I'm not forced to look elsewhere.
I need a fast directory enumerator. So, I remembered
UKDirectoryEnumerator but, was disappointed to find it could only go
one "level." Being a complete programmer at heart I didn't give up and
started to modify the code to read all directories. I have modified it
to work correctly and efficiently (I hope) as possible but there are
some directories that I'm being denied access. From the following code
I get this message:
UKDirectoryEnumerator::nextObjectFullPath - MacOS Error ID= -5000
The error code docs say:
User does not have the correct access to the file
Directory cannot be shared
So, I looked around and found:
OSErr PBHOpenDenySync(HParmBlkPtr paramBlock);
After examination I'm mystified whether or not it will work. First
off, is a "data fork" what I want? I don't think I heading the right
way. I'm very confused as to what I should do to solve my problem.
Once this is finished I'll be sure to let the whole world have it. It
is much better than NSDirectoryEnumerator already, I tested it.
Thanks in advance, Alan
-(id)nextObjectFullPath
{
NSString *path = nil;
if (enny != nil)
{
path = [enny nextObjectFullPath];
}
if (path == nil)
{
[enny dealloc];
enny = nil;
}
if( currIndex >= foundItems )
{
OSErr err = FSGetCatalogInfoBulk( iterator, cacheSize, &foundItems,
NULL, whichInfo, infoCache,
cache, (FSSpec*) NULL,
(HFSUniStr255*) NULL);
if( err != noErr && err != errFSNoMoreItems )
{
NSLog(@"UKDirectoryEnumerator::nextObjectFullPath - MacOS
Error ID= %d",err);
return nil;
}
currIndex = 0;
if( foundItems == 0 )
{
if( err != errFSNoMoreItems )
NSLog(@"UKDirectoryEnumerator::nextObjectFullPath -
FSCatalogInfoBulk returned 0 items, but not errFSNoMoreItems.");
return nil;
}
}
if (enny == nil)
{
path = [NSString stringWithFSRef: &(cache[currIndex++])];
BOOL isDir = NO;
[[NSFileManager defaultManager] fileExistsAtPath: path
isDirectory: &isDir];
if (isDir)
{
enny = [[UKDirectoryEnumerator alloc] initWithPath: path];
}
}
if (path == nil)
{
path = [NSString stringWithFSRef: &(cache[currIndex++])];
}
return path;
}
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden