Memo Akten wrote:

Hi Greg, actually /Users/Shared didn't work either. If I am logged in as admin it works, but if I am logged in as a normal user it doesn't. My code is:

#define LOG_PATH_FOLDER @"/Users/Shared/Library/Preferences/"
#define LOG_FILENAME @"MyLog.plist"
#define LOG_PATH [LOG_PATH_FOLDER stringByAppendingPathComponent:LOG_FILENAME]

NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath: LOG_PATH_FOLDER] == NO) {
NSLog(@"creating folder %@", LOG_PATH_FOLDER);
[fileManager createDirectoryAtPath: LOG_PATH_FOLDER attributes: nil];

Do you understand the Posix permissions and ownership concepts, as applied to files and dirs? If not, you need to learn those.

Do you understand the Posix 'umask' concept and its default value? Again, you should learn that.

Finally, you will need to provide non-nil attributes to createDirectoryAtPath: that specifies all-read, all-write, and all- search permissions on the created dir. If you don't, then the directory will not be writable to anyone except its owner (the user account that creates it), due to how the default umask value affects the created dirs initial permissions.

Whenever you write the log-file, you may also need to specify all- write permissions. It may depend on how you write the file.

You might also consider having a user-specific LOG_FILENAME, constructed from the current user-ID. This means that users won't be overwriting one another's logs. It also means that a log-analyzer would have to coalesce multiple plist files, but that's not too difficult with NSDictionary.

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to