2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
21 namespace Tizen.Applications
24 /// Represents directory information of the application.
26 /// <since_tizen> 3 </since_tizen>
27 public class DirectoryInfo
29 private string _dataPath;
30 private string _cachePath;
31 private string _resourcePath;
33 private string _sharedDataPath;
34 private string _sharedResourcePath;
35 private string _sharedTrustedPath;
37 private string _externalDataPath;
38 private string _externalCachePath;
39 private string _externalSharedDataPath;
41 private string _expansionPackageResourcePath;
43 internal DirectoryInfo()
48 /// Gets the absolute path to the application's data directory, which is used to store private data of the application.
50 /// <since_tizen> 3 </since_tizen>
55 if (_dataPath == null)
56 _dataPath = Interop.AppCommon.AppGetDataPath();
62 /// Gets the absolute path to the application's cache directory, which is used to store temporary data of the application.
64 /// <since_tizen> 3 </since_tizen>
69 if (_cachePath == null)
70 _cachePath = Interop.AppCommon.AppGetCachePath();
76 /// Gets the absolute path to the application resource directory. The resource files are delivered with the application package.
78 /// <since_tizen> 3 </since_tizen>
79 public string Resource
83 if (_resourcePath == null)
84 _resourcePath = Interop.AppCommon.AppGetResourcePath();
90 /// Gets the absolute path to the application's shared data directory, which is used to share data with other applications.
92 /// <since_tizen> 3 </since_tizen>
93 public string SharedData
97 if (_sharedDataPath == null)
98 _sharedDataPath = Interop.AppCommon.AppGetSharedDataPath();
99 return _sharedDataPath;
104 /// Gets the absolute path to the application's shared resource directory, which is used to share resources with other applications.
106 /// <since_tizen> 3 </since_tizen>
107 public string SharedResource
111 if (_sharedResourcePath == null)
112 _sharedResourcePath = Interop.AppCommon.AppGetSharedResourcePath();
113 return _sharedResourcePath;
119 /// Gets the absolute path to the application's shared trusted directory, which is used to share data with a family of trusted applications.
121 /// <since_tizen> 3 </since_tizen>
122 public string SharedTrusted
126 if (_sharedTrustedPath == null)
127 _sharedTrustedPath = Interop.AppCommon.AppGetSharedTrustedPath();
128 return _sharedTrustedPath;
133 /// Gets the absolute path to the application's external data directory, which is used to store data of the application.
135 /// <since_tizen> 3 </since_tizen>
136 public string ExternalData
140 if (_externalDataPath == null)
141 _externalDataPath = Interop.AppCommon.AppGetExternalDataPath();
142 return _externalDataPath;
147 /// Gets the absolute path to the application's external cache directory, which is used to store temporary data of the application.
149 /// <since_tizen> 3 </since_tizen>
150 public string ExternalCache
154 if (_externalCachePath == null)
155 _externalCachePath = Interop.AppCommon.AppGetExternalCachePath();
156 return _externalCachePath;
161 /// Gets the absolute path to the application's external shared data directory, which is used to share data with other applications.
163 /// <since_tizen> 3 </since_tizen>
164 public string ExternalSharedData
168 if (_externalSharedDataPath == null)
169 _externalSharedDataPath = Interop.AppCommon.AppGetExternalSharedDataPath();
170 return _externalSharedDataPath;
175 /// Gets the absolute path to the application's TEP(Tizen Expansion Package) directory. The resource files are delivered with the expansion package.
177 /// <since_tizen> 3 </since_tizen>
178 public string ExpansionPackageResource
182 if (_expansionPackageResourcePath == null)
183 _expansionPackageResourcePath = Interop.AppCommon.AppGetTepResourcePath();
184 return _expansionPackageResourcePath;
189 /// Gets the absolute path to the application's resource control directory, which is used to share the allowed resources of the resource packages.
191 /// <param name="resourceType">The resource type defined in the resource package</param>
192 /// <returns> The absolute path to the application's resource control directory, which is used to share the allowed resources of the resource packages.</returns>
193 /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
194 /// <exception cref="OutOfMemoryException">Thrown in case of out of memory.</exception>
195 /// <exception cref="DirectoryNotFoundException">Thrown in case of nonexistence of resource.</exception>
196 /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
197 /// <since_tizen> 10 </since_tizen>
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 public string GetResourceControlAllowedResource(string resourceType)
201 string path = string.Empty;
202 Interop.AppCommon.AppCommonErrorCode err = Interop.AppCommon.AppGetResControlAllowedResourcePath(resourceType, out path);
203 if (err != Interop.AppCommon.AppCommonErrorCode.None)
207 case Interop.AppCommon.AppCommonErrorCode.InvalidParameter:
208 throw new ArgumentException("Invalid Arguments");
209 case Interop.AppCommon.AppCommonErrorCode.OutOfMemory:
210 throw new OutOfMemoryException("Out of memory");
211 case Interop.AppCommon.AppCommonErrorCode.InvalidContext:
212 throw new InvalidOperationException("Invalid app context");
213 case Interop.AppCommon.AppCommonErrorCode.PermissionDenied:
214 throw new DirectoryNotFoundException(String.Format("Allowed Resource about {0} is not Found", resourceType));
216 throw new InvalidOperationException("Invalid Operation");
224 /// Gets the absolute path to the application's resource control directory, which is used to share the global resources of the resource packages.
226 /// <param name="resourceType">The resource type defined in the resource package</param>
227 /// <returns> The absolute path to the application's resource control directory, which is used to share the global resources of the resource packages.</returns>
228 /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
229 /// <exception cref="OutOfMemoryException">Thrown in case of out of memory.</exception>
230 /// <exception cref="DirectoryNotFoundException">Thrown in case of nonexistence of resource.</exception>
231 /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
232 /// <since_tizen> 10 </since_tizen>
233 [EditorBrowsable(EditorBrowsableState.Never)]
234 public string GetResourceControlGlobalResource(string resourceType)
236 string path = string.Empty;
237 Interop.AppCommon.AppCommonErrorCode err = Interop.AppCommon.AppGetResControlGlobalResourcePath(resourceType, out path);
238 if (err != Interop.AppCommon.AppCommonErrorCode.None)
242 case Interop.AppCommon.AppCommonErrorCode.InvalidParameter:
243 throw new ArgumentException("Invalid Arguments");
244 case Interop.AppCommon.AppCommonErrorCode.OutOfMemory:
245 throw new OutOfMemoryException("Out of memory");
246 case Interop.AppCommon.AppCommonErrorCode.InvalidContext:
247 throw new InvalidOperationException("Invalid app context");
248 case Interop.AppCommon.AppCommonErrorCode.PermissionDenied:
249 throw new DirectoryNotFoundException(String.Format("Allowed Resource about {0} is not Found", resourceType));
251 throw new InvalidOperationException("Invalid Operation");