Mac Cocoa |
Author |
Message |
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Mon Dec 07, 2009 7:23 pm Post subject: Files & Directories |
|
|
MF - Tracking File system changes
"In my cocoa application ,I m trying to track all filesystem changes like copy,
create and renaming or deletion of file and folder." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sat Mar 13, 2010 11:49 pm Post subject: |
|
|
so - Where’s the iPhone MIME type database?
"Basically, you give it a filename, and it uses the path extension to return
the file's MIME type..." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Thu Mar 25, 2010 12:09 am Post subject: |
|
|
Jeff LaMarche - Absolute Filenames
"The full pathname to an item in the Documents directory of an application's
sandbox includes not the name of the application, but a UUID (unique ident-
ifier) instead. When you build and run your application, a new UUID is calcu-
lated if, and only if, something has changed since your last build. If you ha-
ven't made any changes, it keeps running with the previous UUID. Once you
make some changes to code or a resource and re-compile, the UUID chan-
ges, and the stored absolute path no longer points to the right location." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Tue Apr 20, 2010 8:53 pm Post subject: |
|
|
iCodeBlog - Creating a document centric iPhone/iPad application
with own file format using ZipArchive
"If you look at the most of the Apple’s productivity applications you’ll noti-
ce they all use bundles as their output format. ... I am going to be doing
the same today by making my example application create different text
and image files and then zip them together in a single file – this way the
user could then copy this single file over trough iTunes via the file sharing
feature." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sat Feb 26, 2011 4:36 pm Post subject: |
|
|
mf - getResourceValue + NSURLIsDirectoryKey fail
"You need to use the path-based NSFileManager APIs. Get the attributes of
the item and check the NSFileType attribute for if it's equal to NSFileType-
Directory." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Thu Apr 01, 2021 8:55 pm Post subject: |
|
|
so - How can I retrieve read/write disk info?
"You can take a look at XRG, which is an activity monitor for OSX. The whole
disk statistics grabber is in XRGDiskView.m, in the getDISKcounters function.
To sum it up, you get a list of hardrives using the following code..." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Tue Dec 19, 2023 8:29 pm Post subject: |
|
|
adc - Technical Q&A NW09 - Testing for a Network Volume
"... you should use NSURL for this. Construct a URL for any item on
the volume and then call -getResourceValue:forKey:error: to get the
NSURLVolumeIsLocalKey key;"
"... you can use the NSURLVolumeSupportsAdvisoryFileLockingKey key
to determine whether a volume supports advisory locking" |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Tue Dec 19, 2023 8:33 pm Post subject: |
|
|
Code: | // If you're working on general application code, you should use NSURL for this.
// Construct a URL for any item on the volume and then call -getResourceValue:forKey:error: to get the NSURLVolumeIsLocalKey key;
// the returned value will be false (kCFBooleanFalse) for a network volume and true (kCFBooleanTrue) for a local volume.
NSURL *url = (NSURL *)urlRef;
id value = nil;
BOOL ok = [url getResourceValue:&value forKey:NSURLVolumeIsLocalKey error:nil];
if (ok)
NSLog (@"Volume: %@ has this value: %@\n", url, value);
ok = [url getResourceValue:&value forKey:NSURLVolumeSupportsAdvisoryFileLockingKey error:nil];
if (ok)
NSLog (@"Volume: %@ has this value: %@\n", url, value);
CFRelease (urlRef);
if (FSRefMakePath(parentFSRef, (UInt8 *)fullPath, PATH_MAX))
fullPath[0] = '\0';
if (!FSGetCatalogInfo(parentFSRef, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL)) {
if (id_SupportsExclusiveFileAccess (catalogInfo.volume))
NSLog (@"Volume: %hd supports file locking - YES!\n", catalogInfo.volume);
else
NSLog (@"Volume: %hd DOES NOT support file locking\n", catalogInfo.volume);
if (FSGetVolumeParms(catalogInfo.volume, &volParmsInfo, sizeof(GetVolParmsInfoBuffer)) == noErr) {
if (volParmsInfo.vMServerAdr)
NSLog(@"The volume has serverAddr.");
if (volParmsInfo.vMExtendedAttributes & (1 << bIsEjectable)) { // vMAttrib or vMExtendedAttributes (bSupportsExclusiveLocks)
NSLog(@"The volume is a shared volume.");
} else {
NSLog(@"The volume is not a shared volume.");
}
}
}
|
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Thu Mar 21, 2024 9:51 am Post subject: |
|
|
so - iPhone: How to copy a file from resources to documents?
Code: | BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
|
Code: |
NSFileManager *fmngr = [[NSFileManager alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"mydb.sqlite" ofType:nil];
NSError *error;
if(![fmngr copyItemAtPath:filePath toPath:[NSString stringWithFormat:@"%@/Documents/mydb.sqlite", NSHomeDirectory()] error:&error]) {
// handle the error
NSLog(@"Error creating the database: %@", [error description]);
}
[fmngr release];
|
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3157 Location: Europe
|
Posted: Mon Sep 30, 2024 7:21 pm Post subject: |
|
|
so - Mac File association not working. Why or how to debug?
"You could investigate using the lsregister command:
alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'
lsregister -lint -f /path/to/your.app
(I'm using Lion. On a different version of the Mac OS, it's possible that the path
to lsregister is different.)" |
|
Back to top |
|
|
|