简体   繁体   English

在Mac上的哪里放置应用程序数据和临时文件

[英]where to put application data and temp files on mac

We have a Windows Java desktop application that creates some configuration files at %APPDATA% and creates logs at %TEMP% location. 我们有一个Windows Java桌面应用程序,该应用程序在%APPDATA%处创建一些配置文件 ,并在%TEMP%位置处创建日志 Now we are planning to release that desktop application for Mac OS X. We are facing following difficulties: 现在,我们计划发布适用于Mac OS X的桌面应用程序。我们面临以下困难:

  1. We do not want to keep application data within .app (file extension app) so please suggest where else we can keep our configuration files. 我们不想将应用程序数据保留在.app (文件扩展名应用程序)中,因此请提出其他可以保存配置文件的地方。
  2. We do not want to keep temporary files at %TEMP% location in Mac OS X because Mac OS X automatically cleans the %TEMP% location as per schedule. 我们不希望在Mac OS X中将临时文件保留在%TEMP%位置,因为Mac OS X会根据计划自动清除%TEMP%位置。

So we do not want data lose from temp and do not want to keep data with in .app . 因此,我们不希望数据因温度而丢失,也不想将数据保留在.app中 Please suggest. 请提出建议。

Thanks 谢谢

You should probably put the files under /Library/Application Support/<your app> or ~/Library/Application Support/<your app> 您可能应该将文件放在/Library/Application Support/<your app>~/Library/Application Support/<your app>

If the resources apply to all users on the system, such as document templates, place them in /Library/Application Support . 如果资源适用于系统上的所有用户(例如文档模板),请将它们放在/Library/Application Support If the resources are user-specific, such as workspace configuration files, place them in the current user's ~/Library/Application Support directory. 如果资源是特定于用户的,例如工作空间配置文件,请将其放置在当前用户的~/Library/Application Support目录中。

Source: Determining Where to Store Your App-Specific Files 来源: 确定特定于应用程序的文件的存储位置

We do not want to keep application data within .app (file extension app) so please suggest where else we can keep our configuration files. 我们不想将应用程序数据保留在.app(文件扩展名应用程序)中,因此请提出其他可以保存配置文件的地方。

Use Preference API 使用Preference API

We do not want to keep temporary files at %TEMP% location in MAC OS because MAC OS automatically clean %TEMP% location as per schedule. 我们不希望将临时文件保留在MAC OS的%TEMP%位置,因为MAC OS会根据计划自动清除%TEMP%的位置。

Create a dir under user.home to keep temp data user.home下创建一个目录以保留临时数据

Either ~/Library/Application Support or ~/Library/Caches come to mind. 可以想到~/Library/Application Support~/Library/Caches Use the APIs if possible. 如果可能,请使用API​​。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM