سؤال

I'm using a Mac. I need to rename a file in the /Library/Application Support/AppName/filename.aiff

This is the system library and not /User/username/Library...

I'm using the rename(old name, new name) function. This function doesn't work (even though it doesn't return an error) if I place the file in the /Library/Application Support/AppName directory but it works properly if I place the file, for example, in /User/username/Documents/filename.aiff.

I don't know what the problem is. Any help would be appreciated. Thanks!

هل كانت مفيدة؟

المحلول

You don't own the directory you're trying to move files into:

  • /Users/Username/... is a user owned directory, so you're allowed to manipulate files there.

  • /Library is not a user owned directory.

In order to manipulate files in a non-user owned directory you would need elevated permissions. Instead of using /Library you should be using ~/Library, which is the user owned directory. ~/Library is the shorthand name for /Users/Username/Library.

نصائح أخرى

If the rename is working fine in other path means the problem should be related to permission to access file or with the path searched for file.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top