Temp folder in MAC for specific requirement - objective-c

My requirement is, for each user uses my application there will be set of files created for the user. I am looking for right folder in Mac (Similar to C:\Windows\Temp in windows)
Condition:
Folder should be accessible to all users.
Content should not be deleted after logoff.
Folder should not be GUID based like echo $TMPDIR. Path should be static irrespective of user.
Any logged in user should be able to create directory there (even non admin
users).
If you know specific directory, please let me know how do we get this path programetically in objective C.

You can try NSApplicationSupportDirectory or NSCachesDirectory
NSString *downloadPath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:#"MyApp"];

You are probably looking for the "Shared" folder which is located in /Users.
"The Shared folder is located in the Users folder on your hard disk, with your home folder and the home folders of any other people who have accounts on your Mac. You can use the Shared folder to share files with other users on your Mac. The Shared folder is set up so that all users on your Mac can open files in the folder and copy files to it."
This is not a "temporary" folder, whose content will eventually be deleted by the system!
See also: OS X Mavericks: What are the Shared and Public folders?
Unfortunately, there is no corresponding NSSearchPathDirectory constant which would return the path via NSFileManagers method URLsForDirectory:inDomains:.
See also: URLsForDirectory:inDomains:

Related

How to save StorageFolder

I am creating a (sort-of) downloading manager for windows 8 as a metro app. I need to let the user pick his download directory.
So we can get a reference to a folder using the folder picker:
Windows.storate.Pickers.FolderPicker.pickSingleFolderAsync.then(function (folder)
{
//myFolder
folder
}
Now my question is how would I save this folder reference, so that I can still access it after the user closes the app?
There seems to be applicationData that we can use, but does that keep the folder permission in-tact?
I'm using HTML+JS, though since this is an API question it doesn't really matter.
The recommended way to keep track of the folder is to use the AccessCache APIs, which will keep track of the files and folders your app has been given permissions for from the pickers.
To store a folder in the cache:
var folder = //Get a folder from the picker
var storageItemAccessList = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList;
storageItemAccessList.Add(folder,"identifyingString");
And to get the same folder out of the cache later use GetFolderAsync with the identifying string that you used when you stored the folder.
Note that the folder will be kept in the cache even if it has been deleted on the disk. You will get a FileNotFound exception when you try and open it though.

Move a file from the current users desktop?

I was making a installer for some program I made, and I was wondering if I could copy the folder with the contents from the Current Users desktop to another area, how would I do so?Im using: My.Computer.FileSystem.MoveFile("", "")
Move the folder "Emailer" (on the desktop) to System files (x86)
To acces path to the desktop use:
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
After you've obtained the desktop location (as Garath has pointed out in his answer), check out File.Move in the System.IO namespace. e.g
File.Move(path, path2);
http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx

No permissions to save QTP's Object Repositories on shared network folders

Whenever I try to save Object Repositories on my company's shared network folders, QTP complains by saying:
"You do not have the required permission to save in this folder. Do you want to save the file in the My Documents folder instead?"
Thing is, I do have permission to read and write on the folder to which I am trying to save. Moreover, I don't have admin privileges, so running QTP as Admin isn't possible. How can this be solved?
QTP is able to save to shared network folders AND it does have the permission to do it.
The trick is to use the full UNC path. This means that if you wanted to save the file GlobalStore.tsr inside of:
\\somewhere.corpnet.com\Groups\QA\Automation\Object Repository\
You would put in the 'File name' field the whole path:
\\somewhere.corpnet.com\Groups\QA\Automation\Object Repository\GlobalStore.tsr

How to publish/code AIR app that will load an XML file and images from the file system?

I'm creating an AIR app that will load an XML file (that can be edited by the user). It will load certain images specified by the XML file.
I'm currently using File.desktopDirectory.resolvePath() to access the XML file and the images from the desktop.
The AS3 reference for the File class specifies these static properties to access files.
File.applicationStorageDirectory—a storage directory unique to each installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory
Using these would guarantee that the directories resolve correctly for different OS platforms.
So, is my current approach of just placing the XML file and the images(under subfolders) on the desktop the way to go? The user needs to be able to access the XML file to edit it and the folders to add/remove images. Is there an alternative to doing this? I don't think I can put it in the applicationDirectory, b/c the documentation warns against putting anything there that may change.

Documents directory in objective C

In Xcode, the Resources folder links to the NSDocumentsFolder of the app? Or what else?
Is there a way to see the files in NSDocumentFolder without write code?
No the resource folder in Xcode does not link to the document directory, it is just imaginary folder for organization in xcode. However there you could see the content of your document directory by browsing to the folder in the simulator.
The folders you use in XCode will not be copied to your application bundle even though all their content (as well as anything else you have in your XCode project...excluding compiled resources) will be flatly copied into your Bundle Folder. If what you need is accessing the Documents folder on an iOS app or in a the User's library you can access it (by code, I'm sorry) with:
NSString *documentFolderPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
And anything you need to be in there you will have to copy by code.