HasInvalidCharInFilePath() public static method

public static HasInvalidCharInFilePath ( string filePath ) : bool
filePath string
return bool
Esempio n. 1
0
        public static bool HasInvalidCharInFilePath(string filePath)
        {
            char invalidChar;
            int  invalidCharIndex;

            return(PackageImport.HasInvalidCharInFilePath(filePath, out invalidChar, out invalidCharIndex));
        }
Esempio n. 2
0
        public static bool HasInvalidCharInFilePath(string filePath)
        {
            char c;
            int  num;

            return(PackageImport.HasInvalidCharInFilePath(filePath, out c, out num));
        }
            public override void FetchData()
            {
                int rootDepth = -1; // -1 so its children will have 0 depth

                m_RootItem = new PackageImportTreeViewItem(null, "Assets".GetHashCode(), rootDepth, null, "InvisibleAssetsFolder");

                bool initExpandedState = true;

                if (initExpandedState)
                {
                    m_TreeView.state.expandedIDs.Add(m_RootItem.id);
                }

                ImportPackageItem[] items = m_PackageImportView.packageItems;

                Dictionary <string, PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeViewItem>();

                for (int i = 0; i < items.Length; i++)
                {
                    var item = items[i];

                    if (PackageImport.HasInvalidCharInFilePath(item.destinationAssetPath))
                    {
                        continue; // Do not add invalid paths (we already warn the user with a dialog in PackageImport.cs)
                    }
                    string filename   = Path.GetFileName(item.destinationAssetPath).ConvertSeparatorsToUnity();
                    string folderPath = Path.GetDirectoryName(item.destinationAssetPath).ConvertSeparatorsToUnity();

                    // Ensure folders. This is for when installed packages have been moved to other folders.
                    TreeViewItem targetFolder = EnsureFolderPath(folderPath, treeViewFolders, initExpandedState);

                    // Add file to folder
                    if (targetFolder != null)
                    {
                        int id      = item.destinationAssetPath.GetHashCode();
                        var newItem = new PackageImportTreeViewItem(item, id, targetFolder.depth + 1, targetFolder, filename);
                        targetFolder.AddChild(newItem);

                        if (initExpandedState)
                        {
                            m_TreeView.state.expandedIDs.Add(id);
                        }

                        // We need to ensure that the folder is available for
                        // EnsureFolderPath on subsequent iterations.
                        if (item.isFolder)
                        {
                            treeViewFolders[item.destinationAssetPath] = newItem;
                        }
                    }
                }

                if (initExpandedState)
                {
                    m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                this.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem("Assets".GetHashCode(), 0, null, "InvisibleAssetsFolder");
                ((PackageImportTreeView.PackageImportTreeViewItem) this.m_RootItem).isFolder = true;
                bool flag = this.m_TreeView.state.expandedIDs.Count == 0;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                Dictionary <string, AssetsItem> dictionary = new Dictionary <string, AssetsItem>();

                AssetsItem[] assetItems = this.m_AssetItems;
                for (int i = 0; i < assetItems.Length; i++)
                {
                    AssetsItem assetsItem = assetItems[i];
                    if (assetsItem.assetIsDir == 1)
                    {
                        dictionary[assetsItem.pathName] = assetsItem;
                    }
                }
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                AssetsItem[] assetItems2 = this.m_AssetItems;
                for (int j = 0; j < assetItems2.Length; j++)
                {
                    AssetsItem assetsItem2 = assetItems2[j];
                    if (assetsItem2.assetIsDir != 1)
                    {
                        if (!PackageImport.HasInvalidCharInFilePath(assetsItem2.pathName))
                        {
                            string       fileName      = Path.GetFileName(assetsItem2.pathName);
                            string       directoryName = Path.GetDirectoryName(assetsItem2.pathName);
                            TreeViewItem treeViewItem  = this.EnsureFolderPath(directoryName, dictionary, treeViewFolders, flag);
                            if (treeViewItem != null)
                            {
                                int hashCode = assetsItem2.pathName.GetHashCode();
                                treeViewItem.AddChild(new PackageImportTreeView.PackageImportTreeViewItem(hashCode, treeViewItem.depth + 1, treeViewItem, fileName)
                                {
                                    item = assetsItem2
                                });
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
Esempio n. 5
0
 private static bool IsAllFilePathsValid(ImportPackageItem[] assetItems, out string errorMessage)
 {
     foreach (ImportPackageItem assetItem in assetItems)
     {
         char invalidChar;
         int  invalidCharIndex;
         if (!assetItem.isFolder && PackageImport.HasInvalidCharInFilePath(assetItem.destinationAssetPath, out invalidChar, out invalidCharIndex))
         {
             errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", (object)assetItem.destinationAssetPath, (object)(int)invalidChar, (object)invalidCharIndex);
             return(false);
         }
     }
     errorMessage = string.Empty;
     return(true);
 }
            public override void FetchData()
            {
                int depth = -1;

                base.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem("Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                ((PackageImportTreeView.PackageImportTreeViewItem)base.m_RootItem).isFolder = true;
                bool initExpandedState = base.m_TreeView.state.expandedIDs.Count == 0;

                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id);
                }
                Dictionary <string, AssetsItem> packageFolders = new Dictionary <string, AssetsItem>();

                foreach (AssetsItem item in this.m_AssetItems)
                {
                    if (item.assetIsDir == 1)
                    {
                        packageFolders[item.pathName] = item;
                    }
                }
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                foreach (AssetsItem item2 in this.m_AssetItems)
                {
                    if ((item2.assetIsDir != 1) && !PackageImport.HasInvalidCharInFilePath(item2.pathName))
                    {
                        string       fileName      = Path.GetFileName(item2.pathName);
                        string       directoryName = Path.GetDirectoryName(item2.pathName);
                        TreeViewItem parent        = this.EnsureFolderPath(directoryName, packageFolders, treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(item2.pathName.GetHashCode(), parent.depth + 1, parent, fileName)
                            {
                                item = item2
                            };
                            parent.AddChild(child);
                        }
                    }
                }
                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                int depth = -1;

                base.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool initExpandedState = true;

                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int i = 0; i < items.Length; i++)
                {
                    ExportPackageItem itemIn = items[i];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath))
                    {
                        string       fileName      = Path.GetFileName(itemIn.assetPath);
                        string       directoryName = Path.GetDirectoryName(itemIn.assetPath);
                        TreeViewItem parent        = this.EnsureFolderPath(directoryName, treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild(child);
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.assetPath] = child;
                            }
                        }
                    }
                }
                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Sort();
                }
            }
Esempio n. 8
0
 private static bool IsAllFilePathsValid(AssetsItem[] assetItems, out string errorMessage)
 {
     for (int i = 0; i < assetItems.Length; i++)
     {
         AssetsItem assetsItem = assetItems[i];
         if (assetsItem.assetIsDir != 1)
         {
             char c;
             int  num;
             if (PackageImport.HasInvalidCharInFilePath(assetsItem.pathName, out c, out num))
             {
                 errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", assetsItem.pathName, (int)c, num);
                 return(false);
             }
         }
     }
     errorMessage = string.Empty;
     return(true);
 }
Esempio n. 9
0
 private static bool IsAllFilePathsValid(ImportPackageItem[] assetItems, out string errorMessage)
 {
     for (int i = 0; i < assetItems.Length; i++)
     {
         ImportPackageItem importPackageItem = assetItems[i];
         if (!importPackageItem.isFolder)
         {
             char c;
             int  num;
             if (PackageImport.HasInvalidCharInFilePath(importPackageItem.destinationAssetPath, out c, out num))
             {
                 errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", importPackageItem.destinationAssetPath, (int)c, num);
                 return(false);
             }
         }
     }
     errorMessage = string.Empty;
     return(true);
 }
            public override void FetchData()
            {
                int depth = -1;

                this.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool flag = true;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ImportPackageItem[] packageItems = this.m_PackageImportView.packageItems;
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> dictionary = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                for (int i = 0; i < packageItems.Length; i++)
                {
                    ImportPackageItem importPackageItem = packageItems[i];
                    if (!PackageImport.HasInvalidCharInFilePath(importPackageItem.destinationAssetPath))
                    {
                        string       fileName      = Path.GetFileName(importPackageItem.destinationAssetPath);
                        string       directoryName = Path.GetDirectoryName(importPackageItem.destinationAssetPath);
                        TreeViewItem treeViewItem  = this.EnsureFolderPath(directoryName, dictionary, flag);
                        if (treeViewItem != null)
                        {
                            int hashCode = importPackageItem.destinationAssetPath.GetHashCode();
                            PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = new PackageImportTreeView.PackageImportTreeViewItem(importPackageItem, hashCode, treeViewItem.depth + 1, treeViewItem, fileName);
                            treeViewItem.AddChild(packageImportTreeViewItem);
                            if (flag)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (importPackageItem.isFolder)
                            {
                                dictionary[importPackageItem.destinationAssetPath] = packageImportTreeViewItem;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                int depth = -1;

                this.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool flag = true;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> dictionary = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int i = 0; i < items.Length; i++)
                {
                    ExportPackageItem exportPackageItem = items[i];
                    if (!PackageImport.HasInvalidCharInFilePath(exportPackageItem.assetPath))
                    {
                        string       displayName  = Path.GetFileName(exportPackageItem.assetPath).ConvertSeparatorsToUnity();
                        string       folderPath   = Path.GetDirectoryName(exportPackageItem.assetPath).ConvertSeparatorsToUnity();
                        TreeViewItem treeViewItem = this.EnsureFolderPath(folderPath, dictionary, flag);
                        if (treeViewItem != null)
                        {
                            int hashCode = exportPackageItem.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(exportPackageItem, hashCode, treeViewItem.depth + 1, treeViewItem, displayName);
                            treeViewItem.AddChild(packageExportTreeViewItem);
                            if (flag)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (exportPackageItem.isFolder)
                            {
                                dictionary[exportPackageItem.assetPath] = packageExportTreeViewItem;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
Esempio n. 12
0
            public override void FetchData()
            {
                this.m_RootItem = (TreeViewItem) new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem)null, "Assets".GetHashCode(), -1, (TreeViewItem)null, "InvisibleAssetsFolder");
                bool initExpandedState = true;

                if (initExpandedState)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int index = 0; index < items.Length; ++index)
                {
                    ExportPackageItem itemIn = items[index];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath))
                    {
                        string       fileName = Path.GetFileName(itemIn.assetPath);
                        TreeViewItem parent   = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.assetPath), treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild((TreeViewItem)exportTreeViewItem);
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.assetPath] = exportTreeViewItem;
                            }
                        }
                    }
                }
                if (!initExpandedState)
                {
                    return;
                }
                this.m_TreeView.state.expandedIDs.Sort();
            }