Beispiel #1
0
        /// <summary>
        /// Transforme un nom d'objet ou de fichier de façon à ce qu'il respecte une longueur de 8 caractères maxi et son unicité.
        /// This transformation is used with 3D meshes, materials, texture names.
        /// </summary>
        /// <param name="objectName">nom à convertir, sans chemin s'il s'agit d'un fichier</param>
        /// <returns>Un nom unique, ou null s'il s'agit d'une chaîne vide ou nulle</returns>
        public static string NormalizeName(string objectName)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                return(null);
            }

            // Récupération du nom sans extension
            string name = File2.GetNameFromFilename(objectName);

            if (name.Length <= 8)
            {
                // Length <= 8: string is filled with 0s
                for (int i = name.Length; i < 8; i++)
                {
                    name += "\0";
                }
                // BUG_: name is returned
                return(name);
            }

            // Récupération des caractères dépassant le 8e
            char[] nameChars = name.Substring(0, 8).ToCharArray();
            char[] overFlow  = name.Substring(8).ToCharArray();

            // Pour chaque caractère dépassant, on va ajouter sa valeur ASCII aux caractères de début de chaîne
            // EVO_84: found how to manage >16 characters : modulo 8
            for (int pos = 0; pos < overFlow.Length; pos++)
            {
                nameChars[pos % 8] = (char)(nameChars[pos % 8] + overFlow[pos]);
            }

            return(String2.CharArrayToString(nameChars));
        }
Beispiel #2
0
        /// <summary>
        /// Handles packed file renaming. Extensions can't be changed for now.
        /// BNK is automatically saved.
        /// </summary>
        /// <param name="renamedPackedFile"></param>
        /// <param name="newFileName"></param>
        private void _RenamePackedFile(PackedFile renamedPackedFile, string newFileName)
        {
            if (renamedPackedFile != null && !string.IsNullOrEmpty(newFileName))
            {
                // Changing file info node should be sufficient...
                FileInfoNode infoNode = _FileInfoByPathList[renamedPackedFile.filePath];

                infoNode.name = File2.GetNameFromFilename(newFileName);
                renamedPackedFile.fileName = newFileName;

                // Final saving
                Save();
            }
        }
Beispiel #3
0
        protected override void _Process()
        {
            // Parameters
            string fileName    = _GetParameter(PatchInstructionParameter.ParameterName.fileName);
            string destination = _GetParameter(PatchInstructionParameter.ParameterName.destination);

            if (destination == null)
            {
                destination = @".\" + File2.GetNameFromFilename(fileName);
            }
            else
            {
                if (Directory.Exists(destination))
                {
                    // It's a directory. File name must be appended
                    destination += @".\" + File2.GetNameFromFilename(fileName);
                }
            }

            Tools.RestoreFile(fileName, destination);
        }
Beispiel #4
0
        /// <summary>
        /// Met à jour le champ cible selon le nom de fichier indiqué.
        /// (si ce champ est vide)
        /// </summary>
        /// <param name="fileName">nom de fichier</param>
        private void _SetChampCible(string fileName)
        {
            string fileNameWithoutExt = File2.GetNameFromFilename(fileName);

            new2DBFilePath.Text = string.Concat(fileNameWithoutExt, _SUFFIX_NEW_FILE, LibraryConstants.EXTENSION_2DB_FILE);
        }