예제 #1
0
파일: Storage.cs 프로젝트: yunmiha/TizenFX
        internal Storage(int storageID, Interop.Storage.StorageArea storageType, Interop.Storage.StorageState storagestate, string rootDirectory, Interop.Storage.StorageDevice devicetype, string fstype, string fsuuid, bool primary, int flags)
        {
            Id              = storageID;
            _storagetype    = storageType;
            RootDirectory   = rootDirectory;
            _state          = storagestate;
            _devicetype     = devicetype;
            _fstype         = fstype;
            _fsuuid         = fsuuid;
            _primary        = primary;
            _flags          = flags;
            information_set = true;

            Interop.Storage.ErrorCode err = Interop.Storage.StorageGetTotalSpace(Id, out _totalSpace);
            if (err != Interop.Storage.ErrorCode.None)
            {
                Log.Warn(LogTag, string.Format("Failed to get total storage space for storage Id: {0}. err = {1}", Id, err));
            }

            s_stateChangedEventCallback = (id, state, userData) =>
            {
                if (id == Id)
                {
                    _state = state;
                    s_stateChangedEventHandler?.Invoke(this, EventArgs.Empty);
                }
            };
        }
예제 #2
0
파일: Storage.cs 프로젝트: yunmiha/TizenFX
        /// <summary>
        /// Absolute path for a given directory type in the storage.
        /// </summary>
        /// <remarks>
        /// The returned directory path may not exist, so you must make sure that it exists before using it.
        /// For accessing internal storage except the ringtones directory, the application should have http://tizen.org/privilege/mediastorage privilege.
        /// For accessing ringtones directory, the application should have http://tizen.org/privilege/systemsettings privilege.
        /// For accessing external storage, the application should have http://tizen.org/privilege/externalstorage privilege.
        /// </remarks>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="dirType">Directory type.</param>
        /// <returns>Absolute path for a given directory type in the storage.</returns>
        /// <feature> http://tizen.org/feature/storage.external </feature>
        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory exception.</exception>
        /// <exception cref="NotSupportedException">Thrown when the storage is not supported or the application does not have the permission to access the directory path.</exception>
        /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
        /// <privilege>http://tizen.org/privilege/systemsettings</privilege>
        /// <privilege>http://tizen.org/privilege/externalstorage</privilege>
        /// <example>
        /// <code>
        /// // To get the video directories for all the supported storage,
        /// var storageList = StorageManager.Storages as List&lt;Storage&gt;;
        /// foreach (var storage in storageList)
        /// {
        ///     string pathForVideoDir = storage.GetAbsolutePath(DirectoryType.Videos);
        /// }
        /// </code>
        /// </example>
        public string GetAbsolutePath(DirectoryType dirType)
        {
            string path;

            Interop.Storage.ErrorCode err = Interop.Storage.StorageGetAbsoluteDirectory(Id, (Interop.Storage.DirectoryType)dirType, out path);
            if (err != Interop.Storage.ErrorCode.None)
            {
                Log.Warn(LogTag, string.Format("Failed to get package Id. err = {0}", err));
                switch (err)
                {
                case Interop.Storage.ErrorCode.InvalidParameter:
                    throw new ArgumentException("Invalid Arguments");

                case Interop.Storage.ErrorCode.OutOfMemory:
                    throw new OutOfMemoryException("Out of Memory");

                case Interop.Storage.ErrorCode.NotSupported:
                    throw new NotSupportedException("Storage Not Supported");

                default:
                    throw new InvalidOperationException("Error = " + err);
                }
            }
            return(path);
        }
예제 #3
0
파일: Storage.cs 프로젝트: yunmiha/TizenFX
 private void RegisterStateChangedEvent()
 {
     Interop.Storage.ErrorCode err = Interop.Storage.StorageSetStateChanged(Id, s_stateChangedEventCallback, IntPtr.Zero);
     if (err != Interop.Storage.ErrorCode.None)
     {
         Log.Warn(LogTag, string.Format("Failed to Register state changed event callback for storage Id: {0}. err = {1}", Id, err));
     }
 }
예제 #4
0
 private static void UnregisterChangedEvent(StorageArea type)
 {
     Interop.Storage.ErrorCode err = Interop.Storage.StorageUnsetChanged((int)type, s_ChangedEventCallback);
     if (err != Interop.Storage.ErrorCode.None)
     {
         Log.Warn(LogTag, string.Format("Failed to Unreegister changed event callback for external storage. err = {0}", err));
     }
 }
예제 #5
0
        private static void UnregisterChangedEvent(StorageArea type)
        {
            Interop.Storage.ErrorCode err = Interop.Storage.StorageUnsetChanged((int)type, s_ChangedEventCallback);
            if (err != Interop.Storage.ErrorCode.None)
            {
                Log.Warn(LogTag, string.Format("Failed to Unreegister changed event callback for external storage. err = {0}", err));

                switch (err)
                {
                case Interop.Storage.ErrorCode.NotSupported:
                    throw new NotSupportedException("Storage Not Supported");

                default:
                    break;
                }
            }
        }
예제 #6
0
파일: Storage.cs 프로젝트: prjung/TizenFX
        internal Storage(int storageID, Interop.Storage.StorageArea storageType, Interop.Storage.StorageState storagestate, string rootDirectory)
        {
            Id            = storageID;
            StorageType   = (StorageArea)storageType;
            RootDirectory = rootDirectory;
            _state        = storagestate;

            Interop.Storage.ErrorCode err = Interop.Storage.StorageGetTotalSpace(Id, out _totalSpace);
            if (err != Interop.Storage.ErrorCode.None)
            {
                Log.Warn(LogTag, string.Format("Failed to get total storage space for storage Id: {0}. err = {1}", Id, err));
            }

            s_stateChangedEventCallback = (id, state, userData) =>
            {
                if (id == Id)
                {
                    _state = state;
                    s_stateChangedEventHandler?.Invoke(this, EventArgs.Empty);
                }
            };
        }