예제 #1
0
        /// <summary>
        /// Gets the path of data table storage.
        /// </summary>
        /// <param name="location">One of the <see cref="DataTableStorageLocation"/></param>
        /// <returns>The path of data table storage.</returns>
        public static string GetDataTableStoragePath(DataTableStorageLocation location)
        {
            if (dataTablesLocationMap.ContainsKey(location))
            {
                return(dataTablesLocationMap[location]);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Called as the new window is opened.
        /// </summary>
        private void Awake()
        {
            DataTablePreferences preferencesData = LoadPreferencesData();

            if (preferencesData != null)
            {
                this.preferencesData = preferencesData;
            }
            else
            {
                this.preferencesData = CreateDefaultPreferencesData();
            }

            lastDataTablesStorageLocation = ObjectUtil.DeepClone(this.preferencesData.DataTablesStorageLocation);
        }
예제 #3
0
        /// <summary>
        /// Moves the database files.
        /// </summary>
        /// <param name="oldLocation">The old location.</param>
        /// <param name="newLocation">The new location.</param>
        private void MoveDbFiles(DataTableStorageLocation oldLocation, DataTableStorageLocation newLocation)
        {
            string oldPath = DataImport.GetDataTableStoragePath(oldLocation);

            if (!Directory.Exists(oldPath))
            {
                Directory.CreateDirectory(oldPath);
            }

            string[] filePaths = Directory.GetFiles(oldPath);

            if (filePaths != null && filePaths.Length > 0)
            {
                // Check new path.
                string newPath = DataImport.GetDataTableStoragePath(newLocation);

                if (!Directory.Exists(newPath))
                {
                    Directory.CreateDirectory(newPath);
                }

                // Move files.
                for (int i = 0, length = filePaths.Length; i < length; ++i)
                {
                    try
                    {
                        string   filePath = filePaths[i];
                        FileInfo fileInfo = new FileInfo(filePath);

                        if (newLocation == DataTableStorageLocation.ResourcesPath)
                        {
                            // Files move to Resources folder need to be renamed.
                            if (fileInfo.Extension == DataImport.boxDbFileExtension)
                            {
                                string destPath = Path.Combine(newPath, fileInfo.GetFileNameWithoutExtension() + QuickUnityEditorApplication.BytesAssetFileExtension);
                                File.Move(filePath, destPath);
                            }
                        }
                        else if (oldLocation == DataTableStorageLocation.ResourcesPath)
                        {
                            // Files move from Resources folder also need to be renamed.
                            if (fileInfo.Extension == QuickUnityEditorApplication.BytesAssetFileExtension)
                            {
                                string destPath = Path.Combine(newPath, fileInfo.GetFileNameWithoutExtension() + DataImport.boxDbFileExtension);
                                File.Move(filePath, destPath);
                            }
                        }
                        else
                        {
                            if (fileInfo.Extension != QuickUnityEditorApplication.MetaFileExtension)
                            {
                                string destPath = Path.Combine(newPath, fileInfo.Name);
                                File.Move(filePath, destPath);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.LogException(exception);
                    }
                }
            }

            // Delete the DataTables folder.
            try
            {
                Directory.Delete(oldPath, true);
                Utils.EditorUtil.DeleteMetaFile(oldPath);
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
            }
        }